wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

DATAFRAME AND SERIES

Total questions: 10

Worksheet time: 7mins

Name
Class
Date
1.

1. Given a Pandas series called Marks, the command which will display the first 3 rows is .

a)

print(Marks.head(3))

b)

print(Marks.Head(3))

c)

print(Marks.heads(3)

d)

print(Marks.Heads(3))

2.

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

a)

A1+A2

b)

sum(A1,A2)

c)

a1+a2

3.

The __________ attribute of a dataframe object returns the row labels of a dataframe.

a)

columns

b)

Columns

c)

Index.Values

d)

index.values

4.

Say true or false, A Dataframe object is mutable.

a)

True

b)

False

5.

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)

6.

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’))

7.

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))

8.

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”)

9.

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

10.

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[]