NEW
Font size
WorksheetsDATAFRAME AND SERIES
Total questions: 10
Worksheet time: 7mins
1. Given a Pandas series called Marks, the command which will display the first 3 rows is .
print(Marks.head(3))
print(Marks.Head(3))
print(Marks.heads(3)
print(Marks.Heads(3))
1. Given the following Series A1 and A2: 1
A1 A2
a 20 a 70
b 10 b 30
c 24 c 84
d 70 d 80
Write the command to find the sum of series A1 and A2
A1+A2
sum(A1,A2)
a1+a2
The __________ attribute of a dataframe object returns the row labels of a dataframe.
columns
Columns
Index.Values
index.values
Say true or false, A Dataframe object is mutable.
True
False
DataFramedf
Age Name
rank1 28 Tom
rank2 34 Jack
rank3 29 Steve
rank4 42 Ricky
Find out the command used to get the following output from the above dataframe,
Age
rank1 28
rank2 34
rank3 29
rank4 42
Print(df[‘Age’])
print(df[‘Age’])
print(df(‘Age’))
Print(df[‘Age’], axis=1)
The instructor wants to know the age of the persons with rank3. Help her to identify the correct set of statement/s from the given options:
a) Print(df.loc[‘rank3’])
b) print(df.iloc[‘rank3’])
c) print(df.loc[‘rank3’])
d) Print(df.loc(‘rank3’))
Which of the following statement/s will give 2 rows from bottom of the dataframe ?
Print(df.tail())
print(df.tail(2))
print(df.tail[2])
print(df.tail(4))
i) Which of the following statement will delete rank2 row from the dataframe ?
df.drop(‘rank2’)
df.drop(rank2)
delete df(rank2)
df.del(“rank2”)
The instructor wants to add a new column, Marks to the dataframe. The values of the marks will be 12, 22, 21, 24. Help him to choose the correct command to do so.
a) Df.columns=[12, 22, 21, 24]
b) df[‘marks’] = [12, 22, 21, 24]
c) df.loc[marks] = [12, 22, 21, 24]
d) Both (b) and (c) are correct
The instructor wants to add a new row to the dataframe. Help him to choose the correct command to do so.
df.loc[]
df.iloc[]
