wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Pandas 1 by RK

Total questions: 62

Worksheet time: 31mins

Name
Class
Date
1.

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

2.

DataFrame in pandas is

a)

1. dimensional array

b)

2. dimensional array

c)

3.dimensional array

d)

4.None of the above

3.

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

4.

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

5.

Which of the following library is similar to Pandas?

a)

a) NumPy

b)

b) RPy

c)

c) SciPy

d)

d) None of the mentioned

6.

Which is not a feature of series

a)

Homogeneous data

b)

Immutable size

c)

Mutable data

d)

Multiple rows

7.

Series can be created from

a)

Array

b)

Dictionary

c)

Scaler value

d)

All of them

8.

Full form of CSV file is

a)

Comma Separated Vault

b)

Comma Separated Value

c)

Common Separated Value

d)

Common System Value

9.

Not a function of Dataframe

a)

Head()

b)

Tail()

c)

loc()

d)

multi()

10.

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

11.

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

12.

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

a)

combine_first

b)

concat()

c)

merge()

13.

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

a)

merge()

b)

combine_first()

c)

concat()

14.

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

a)

iterrows()

b)

iteritems()

15.

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

a)

pop()

b)

at()

c)

drop()

d)

iloc()

16.

Series.tail(3) will return how many values.

a)

3 values from front

b)

3 values from last

c)

5 values

d)

none

17.

To extract subset from Series,the following function is used

a)

row()

b)

column()

c)

loc()

d)

all

18.

we can analyze the data in pandas with :

a)

Series

b)

Dataframe

c)

Both

d)

none

19.

Series in Pandas is

a)

1 Dimensional Array

b)

2 Dimensional array

c)

3 Dimensional array

d)

none of above

20.

Which package should be needed for series

a)

Maths

b)

Statistic

c)

Pandas

d)

Random

21.

Full form of NaN is

a)

Not a Null

b)

Not a Number

c)

Not a Numeric

d)

None of these

22.

pandas is a:

a)

Data Structure

b)

Series

c)

Dataframe

d)

Library

23.

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

24.

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

25.

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

26.

write the output:

import pandas as pd

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

print(s.loc['b':'d'])

a)

b 2

c 3

d 4

dtype: float64

b)

b 2

c 3

d 4

dtype: object

c)

c 3

d 4

dtype: int64

d)

b 2

c 3

d 4

dtype: int64

27.

Give the output of the following code:


>>>import pandas as pd

>>>dict1 = {'AR' : 100, 'VR' : 200, 'AI' : 300}

>>>ser = pd.Series(dict1)

>>>print(ser[1])

a)

AR

b)

100

c)

VR

d)

200

28.
a)

print(ser[2,4])

b)

print(ser[[2:4]])

c)

print(ser[[2,4]])

d)

print(ser[2,3,4])

29.

a)

print(ser[[1,3]])

b)

print(ser[1:3])

c)

print(ser[[1:3]])

d)

print(ser[1,3])

30.

What will be the print statement to display the elements of a series series1 from end till beginning in step 2?

a)

print(series1[::-2])

b)

print(series1[::2])

c)

print(series1[:-2:])

d)

print(series1[:2:])

31.
a)

pd.DataFrame(DICT1, columns=["NAME","DOB"])

b)

pd.DataFrame(DICT1, index=["NAME","DOB"])

c)

pd.DataFrame(DICT1, index=["NAME":"DOB"])

d)

pd.DataFrame(DICT1, columns=["NAME":"DOB"])

32.

a)

print(pd.DataFrame(DICT1, index=[1,2,3], columns=["NAME","SCODE"]))

b)

print(pd.DataFrame(DICT1, index=[501,502,503], columns=["NAME","SCODE"]))

c)

print(pd.DataFrame(DICT1, index=[501,502,503], columns=["NAME":"SCODE"]))

d)

print(pd.DataFrame(DICT1, index=[501:503], columns=["NAME","SCODE"]))

33.

a)

DICT1.drop(504, axis=0)

b)

DICT1.drop(4, axis=0)

c)

DICT1.drop(504, axis=1)

d)

DICT1.drop(4, axis=1)

34.

a)

DICT1[4]>=500

b)

DICT1["SCORE"]>=500

c)

DICT1["SCORE"]<=500

d)

DICT1["SCORE">=500]

35.

a)

DICT1.loc[502:505]

b)

DICT1.loc[:,502:505]

c)

DICT1.iloc[1:5]

d)

DICT1.iloc[1:4]

36.

Basic feature of DataFrame are

a)

homogenous data with mutable size

b)

hetrogenous data with mutable size and values

c)

homogeous data single dimensional

37.

Pandas deals with following data structures

a)

Series

b)

Series and Data Frames

c)

Series, DataFrames and Panel

d)

None of Above

38.

Series.head() will return how many rows.

a)

2

b)

3

c)

4

d)

5

39.

What does this line of code do?

a)

Returns unique values

b)

Checks duplicates

c)

Drops duplicates

d)

Checks index duplicates

40.

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

a)

0

b)

1

c)

2

d)

3

41.

Which function needs a dictionary of array like sequences or a dictionary of another dictionary, to return a DataFrame?

a)

DataFrame.from_items

b)

DataFrame.from_records

c)

DataFrame.from_dict

d)

All of the above

42.

To get the number of dimensions of a Series object, ____________ attribute is displayed

a)

itemsize

b)

size

c)

index

d)

ndim

43.

To check if the Series object contains NAN values, _____________ attribute is displayed.

a)

hasnans

b)

nbytes

c)

ndim

d)

dtype

44.

To get the number of bytes of the Series Data, ___________________ attribute is used.

a)

index

b)

size

c)

itemsize

d)

ndim

45.

While we concat, if we do not want the mechanism for row indexes and want to have new row indexes generated from 0 to n-1, then we can give argument ignore_index as .............

a)

False

b)

True

46.

The axis 0 identifies a dataframe's ..............

a)

rows

b)

columns

c)

values

d)

datatype

47.

To extract row/column from a dataframe, ............. function may be used.

a)

row()

b)

column()

c)

loc()

d)

All of these

48.

The axis 1 identifies a dataframe's ...............

a)

rows

b)

columns

c)

values

d)

datatype

49.

To delete a column from a DataFrame, you may use ............ statement.

a)

remove

b)

del

c)

drop

d)

pop

50.

Ms.Sharma, the class teacher wants to add a new column, the scores of Grade with the values, 'A','B','A','A', to the DataFrame. Help her choose the command to do so:

a)

df.column=[ 'A','B','A','A']

b)

df ['Grade']=[ 'A','B','A','A']

c)

df . loc ['Grade']=[ 'A','B','A','A']

51.

Which among the following is correct to display the column Hospitals from the above dataframe?

a)

print(dtf5 [ Hospitals ])

b)

print(dtf5 . Hospitals )

c)

pring(dtf5 [ 'Hospitals' ])

d)

print(dtf5 { Hospitals })

52.

Among the following which all statements can be used to display the details of Kolkata.

a)

print( dtf5.iloc[2, : ])

b)

print( dtf5.iloc[ 'Kolkata' ])

c)

print( dtf5.loc[ 'Kolkata' ])

d)

print( dtf5.iat[ 'Kolkata' ])

53.

Which of the following commands is used to convert array named "grades" into data frame named "df_grades"?

a)

df_grades = grades

b)

df_grades = pd.DataFrame(grades)

c)

df_grades = pd.DataFrame("grades")

d)

grades = pd.DataFrame(df_grades)

54.

Among the following which all statements can be used to delete the row having index 'Chennai'?

a)

dtf5=dtf5.drop('Chennai')

b)

dtf5.drop('Chennai',axis=0,inplace=True)

c)

dtf5=dtf5.drop('Chennai',axis=1)

d)

dtf5=dtf5.drop(index='Chennai')

55.

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

a)

columns

b)

Columns

c)

Index.Values

d)

index.values

56.

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)

57.

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

58.

For the given DataFrame df, what will be the code to get the value 38?

a)

df . iloc [1,1]

b)

df . Age [222]

c)

df . loc [111]

d)

None of the above

59.

Way to install the pandas library ?

a)

pip install pandas

b)

PIp install pandas

60.

To display third element of a Series object S you will write___

a)

S [ : 3 ]

b)

S [ 2 ]

c)

S [ 3 ]

d)

S [ : 2 ]

61.

_________ function is used to access individual values

a)

it ()

b)

bit ()

c)

at ()

d)

set ()

62.

The insert function requires ____ number of arguments in DataFrame.

a)

1

b)

2

c)

3

d)

4