Question #147694

1. Which of the following can be used to create a DataFrame in Pandas?

A. Pandas Series object
B.2D ndarray
C. Python dict
D. All of the above

2. For the Series s1 and s2 defined below, which of the following statements will give an error?

import pandas as pd
s1 = pd.Series({1: 'Alice', 2: 'Jack', 3: 'Molly'})
s2 = pd.Series({'Alice': 1, 'Jack': 2, 'Molly': 3})

A. s2.loc[1]
B. s1.loc[1]
C. s2[1]
D.s2.iloc[1]

Expert's answer

1. You can make a data frame with pandas from all the first options


So the answer is Option D.

2. Only option A is going to give us a typeError while others will give a definite Output since it is in Series.


So the answer is Option A


LATEST TUTORIALS
APPROVED BY CLIENTS