16. What is the output of the following code? df = pd.DataFrame(np.arange(9).res
ID: 3891418 • Letter: 1
Question
16. What is the output of the following code?df = pd.DataFrame(np.arange(9).reshape((3,3)), columns = list('ABC'))
df.ilo[1] (Points : 1)
A 3
B 4
C 5
A 1
B 2
C 3
0 3
1 4
2 5
0 1
1 2
2 3
Question 17.17. What is the output of the following code?
df = pd.DataFrame(np.arange(9).reshape((3,3)), columns = list('ABC'))
df.ix[0,'A']
(Points : 1) 0
1
2
3 Question 18.18. What is the output of the following code?
df = pd.DataFrame(np.arange(9).reshape((3,3)), columns = list('ABC'))
df.sum(axis =1)
(Points : 1)
A 9
B 12
C 15
A 9
B 15
C 23
0 9
1 12
2 15
0 9
1 15
2 23
Question 19.19. Consider the following dataframe df in pandas.
A B C
0 0.0 1 2
1 NaN 4 5
2 6.0 7 8
what is the result of the following code?
df.dropna() (Points : 1)
A B C
0 0.0 1 2
2 6.0 7 8
B C
0 1 2
1 4 5
2 7 8
B C
0 1 2
2 7 8
A B C
0 0.0 1 2
1 6.0 7 8
Question 20.20. Consider the following dataframe df in pandas.
A B C
0 0.0 1 2
1 NaN 4 5
2 6.0 7 8
what is the result of the following code?
df.ix[1,'A']=0
df.sum() (Points : 1)
A 6.0
B 12.0
C 15.0
0 6.0
1 12.0
2 15.0
A 6.0
B 15.0
C 12.0
0 6.0
1 15.0
2 12.0
Question 21.21. Consider the following dataframe df in pandas.
A B C
0 0.0 1 2
1 0.0 4 5
2 6.0 7 8
what is the result of the following code?
del df[['A','B']]
(Points : 1)
C
0 2
1 5
2 8
A B
0 0.0 1
1 0.0 4
2 6.0 7
A
0 0.0
1 0.0
2 6.0
A B C
0 0.0 1 2
1 0.0 4 5
2 6.0 7 8
Question 22.22. Consider the following dataframe df in pandas.
A B C
0 0.0 1 2
1 0.0 4 5
2 6.0 7 8
what is the result of the following code?
df.drop(0:2)
(Points : 1)
A B C
0 0.0 1 2
1 0.0 4 5
A B C
2 6.0 7 8
A B C
1 0.0 4 5
2 6.0 7 8
A B C
0 0.0 1 2
1 0.0 4 5
2 6.0 7 8
Question 23.23. Consider the following dataframe df in pandas.
A B
0 0 1
1 0 4
2 6 7
What is the result of the following code?
df['C']= pd.Series([0, 0 ,1]) (Points : 1)
A B C
0 0 1 0
1 0 4 0
A B C
0 0 1 0
1 0 4 0
2 6 7 1
A B
0 0 1
1 0 4
2 6 7
3 0 1
4 1 NaN
A B C
1 0 4 0
2 6 7 1
Question 24.24. What is the output of the following code?
var = {'a':1,'b':2}
df = pd.Series(var) (Points : 1)
0 1
1 2
b 1
a 2
a 1
b 2
1 1
2 2
Question 25.25. Consider the following series S1 in pandas,
a NaN
b NaN
c 2.6
d NaN
How many True will be printed in the following code?
S1.notnull() (Points : 1) 1
2
3
4 16. What is the output of the following code?
df = pd.DataFrame(np.arange(9).reshape((3,3)), columns = list('ABC'))
df.ilo[1] (Points : 1)
A 3
B 4
C 5
A 1
B 2
C 3
0 3
1 4
2 5
0 1
1 2
2 3
Explanation / Answer
Q16
The output is
Q17
The output is 0
Q18
Q19
A B C
0 0.0 1 2
2 6.0 7 8
It drops the columns with nan values
Q20
A 6.0
B 12.0
C 15.0
Sum along column values
Q21
C
0 2
1 5
2 8
Q22
A B C
2 6.0 7 8
Q23
A B C
0 0 1 0
1 0 4 0
2 6 7 1
Q24
a 1
b 2
Q25
Only 1 as there is one value which is not Nan
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.