wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Solve Questions on DataFrame

Total questions: 6

Worksheet time: 7mins

Name
Class
Date
1.

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

a)

Print(df[‘Age’])

b)

print(df[‘Age’])

c)

print(df(‘Age’))

d)

Print(df[‘Age’], axis=1)

2.

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)

a) Print(df.loc[‘rank3’])

b)

b) print(df.iloc[‘rank3’])

c)

c) print(df.loc[‘rank3’])

d)

d) Print(df.loc(‘rank3’))

3.

Which of the following statement/s will give 2 rows from bottom of the dataframe ?

a)

Print(df.tail())

b)

print(df.tail(2))

c)

print(df.tail[2])

d)

print(df.tail(4))

4.

i) Which of the following statement will delete rank2 row from the dataframe ?

a)

df.drop(‘rank2’)

b)

df.drop(rank2)

c)

delete df(rank2)

d)

df.del(“rank2”)

5.

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)

a) Df.columns=[12, 22, 21, 24]

b)

b) df[‘marks’] = [12, 22, 21, 24]

c)

c) df.loc[marks] = [12, 22, 21, 24]

d)

d) Both (b) and (c) are correct

6.

The instructor wants to add a new row to the dataframe. Help him to choose the correct command to do so.

a)

df.loc[ ]

b)

df.iloc[ ]