Knowee
Questions
Features
Study Tools

Q.7 What will be output for the following code?import pandas as pdimport numpy as nps = pd.Series(np.random.randn(4))print s.ndim1. 02. 13. 24. 3

Question

Q.7 What will be output for the following code?import pandas as pdimport numpy as nps = pd.Series(np.random.randn(4))print s.ndim1. 02. 13. 24. 3

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output for the given code will be 1.

Explanation: The 'ndim' attribute returns the number of dimensions of the underlying data, in your case it's a Series. In pandas, Series is a one-dimensional labeled array capable of holding any data type. Hence, the output will be 1.

Similar Questions

Write the output of the following code: import pandas as pd Import numpy as np S = pd.Series(np.random.randn(4)) print(S.ndim)210None of the above

What will be the output of following code: import pandas as pd S = pd.Series([11,12,13,14,15,16]) S[1:4] = 20 S = list(S) print(S)[11, 20, 20, 20, 15, 16][20, 20, 20, 20, 15, 16][20, 12, 13, 20, 15, 16][11, 20, 13, 20, 15, 16]

What is the output of the following Python code:Codeimport numpy as npimport pandas as pddata={'name':['Alice','Bob','Ben'], 'order':[1,3,2], 'sector':['Sales','Finance','Marketing'] }df=pd.DataFrame(data)print(df)

Complete the given Python code to get the required output as: Rajasthanimport _________ as pddi = {'Corbett': 'Uttarakhand', 'Sariska':'Rajasthan', 'Kanha': 'Madhya Pradesh’,'Gir':'Gujarat'}NP = ___________. Series( _____ )print(NP[ ___________ ])

Q.13 What will be output for the following code?import numpy as npa = np.array([1,2,3])print a

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.