wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Pandas Dataframe and Series

Total questions: 40

Worksheet time: 24mins

Name
Class
Date
1.

Pandas deals with following data structures

a)

Series

b)

Series and Data Frames

c)

Series, DataFrames and Panel

d)

None of Above

2.

Best way to import the pandas module in your program ?

a)

1.import pandas

b)

2.import pandas as pd

c)

3.from pandas import *

d)

4.All of the above

3.

DataFrame in pandas is

a)

1. dimensional array

b)

2. dimensional array

c)

3.dimensional array

d)

4.None of the above

4.

All pandas data structures are ___ mutable but not always _______mutable.

a)

a) size, value

b)

b) semantic, size

c)

c) value, size

d)

d) none of the mentioned

5.

Which of the following object you get after reading CSV file?

a)

a) DataFrame

b)

b) Character Vector

c)

c) Panel

d)

d) All of the mentioned

6.

Which of the following library is similar to Pandas?

a)

a) NumPy

b)

b) RPy

c)

c) SciPy

d)

d) None of the mentioned

7.

Which is not a feature of series

a)

Homogeneous data

b)

Immutable size

c)

Mutable data

d)

Multiple rows

8.

Series can be created from

a)

Array

b)

Dictionary

c)

Scaler value

d)

All of them

9.

Full form of CSV file is

a)

Comma Separated Vault

b)

Comma Separated Value

c)

Common Separated Value

d)

Common System Value

10.

Not a function of Dataframe

a)

Head()

b)

Tail()

c)

loc()

d)

multi()

11.

Dataframe can contain multiple series

a)

True

b)

False

12.

Which function from the options given below can read the dataset from a large text file?

a)

read_json

b)

read_pickle

c)

read_hdf

d)

read_csv

13.

Which of the following can be used to make a Dataframe?

a)

Series

b)

DataFrame

c)

Structured ndarray

d)

All of the above

14.

Which is the correct Pandas syntax to read in a csv file and assign it to a DataFrame df?

a)

df = read_csv('file.csv')

b)

df = read('file.csv', type = 'csv')

c)

df = pd.read_csv('file.csv')

d)

df = with open('file.csv') as pd.DataFrame

15.

Type the syntax that returns the top 5 rows in DataFrame df with the native Pandas function (not slicing):

(a)  

16.

Among the following functions, which one can be used to combine dataframes when they have similar structure.

a)

combine_first

b)

concat()

c)

merge()

17.

For the concat(), if the axis=1, it will join the dataframes ...............

a)

vertically

b)

horizontally

18.

Which function can be used to combine dataframes based on common fields?

a)

merge()

b)

combine_first()

c)

concat()

19.

Which function views dataframe in the form of vertical subset ie column wise?

a)

iterrows()

b)

iteritems()

20.

Which of the functions can be used to delete column/row from a DataFrame?

a)

pop()

b)

at()

c)

drop()

d)

iloc()

21.

Best way to import the pandas module in your program ?

a)

1.import pandas

b)

2.import pandas as pd

c)

3.from pandas import *

d)

4.All of the above

22.

Which is true for series.

a)

Size is mutable,Values is mutable

b)

size is immutable,values is mutable

c)

size is mutable,values is immutable.

d)

none

23.

To extract subset from Series,the following function is used

a)

row()

b)

column()

c)

loc()

d)

all

24.

Minimum number of argument we require to pass in pandas series ?

a)

0

b)

1

c)

2

d)

3

25.

Full form of NaN is

a)

Not a Null

b)

Not a Number

c)

Not a Numeric

d)

None of these

26.

pandas is a:

a)

Data Structure

b)

Series

c)

Dataframe

d)

Library

27.

Write the output for the following:

import pandas as pd1

s = pd1.Series(5, index=[0, 1, 2, 3])

print(s)

a)

0 5

b)

0 5

1 5

2 5

3 5

dtype: int64

c)

1 5

2 5

2 5

4 5

dtype: int64

d)

0 5

1 5

2 5

3 5

dtype: object

28.

write the output:

import pandas as pd1

s = pd1.Series([1,2,3])

t = pd1.Series([1,2,4])

u=s-t

print (u)

a)

0 1

1 0

2 1

dtype: int64

b)

0 0

1 0

2 1

dtype: int64

c)

0 0

1 0

2 -1

dtype: float64

d)

0 0

1 0

2 -1

dtype: int64

29.

write the output:

import pandas as pd

s=pd.Series([1,2,3,4],index=['a','b','c','d'])

print(s.iloc[2:4])

a)

b 2

c 3

d 4

dtype: int64

b)

b 3

c 4

dtype: int64

c)

c 3

d 4

dtype: int64

d)

none of the above

30.

Which of the functions can be used to delete column/row from a DataFrame?

a)

pop()

b)

at()

c)

drop()

d)

iloc()

31.

Full form of CSV file is

a)

Comma Separated Vault

b)

Comma Separated Value

c)

Common Separated Value

d)

Common System Value

32.

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

33.

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)

34.

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

35.

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

36.

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

37.

PANDAS stands for _________________

a)

Panel Data Analyst

b)

Panel Data Analyse

c)

Panel Data

d)

Panel Database

38.

To display third element of a Series object S, you will write

a)

S[:3]

b)

S[02]

c)

S[2]

d)

S[:2]

39.

To display the 3rd, 4th and 5th columns from the 6th to 9th rows of a dataframe you can write

a)

DF.LOC[6:9, 3:5]

b)

DF.LOC[6:10, 3:6]

c)

DF.iloc[6:10, 3:6]

d)

DF.iloc[6:9, 3:5]

40.

What will be the output for the following code ?

>>> import pandas as pd

>>> S = pd. Series([1,2,3,4,5],index = ['a', 'b', 'c', 'd', 'e'])

>>> print ( s[ 'a'] )

a)

2

b)

1

c)

3

d)

4