wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Pandas Quiz Class 12

Total questions: 146

Worksheet time: 1hrs 16mins

Name
Class
Date
1.

In a DataFrame, axis-0 is for

a)

Columns

b)

Rows and Columns both

c)

Rows

d)

None of these

2.

To get the Transpose of a DataFrame D1, you can write _____________.

a)

D1.T

b)

D1.Transpose

c)

D1.swap

d)

All of these

3.

To display the 3rd, 4th and 5th columns from the 6th to 9th rows of a dataframe DF, 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]

4.

Which among the following can be used to create a DataFrame in Pandas?

a)

A scalar value

b)

An ndarray

c)

A python dictionary

d)

All of these

5.

To delete a row from a DataFrame, you may use the __________ statement.

a)

remove

b)

delete

c)

drop

d)

cancel

6.

You have a Pandas dataframe (assigned to the variable df) with the given data. Which of the following code snippets will return the temperature and rainfall of rows 2 and 3?

a)

df[['temperature','rainfall']][1:3]

b)

df['temperature', 'rainfall'][1:3]

c)

df.iloc[1:3]

d)

df.iloc[1:3,1:2]

7.

Select the most suitable option. Statement I: A DataFrame is size mutable. Statement II: A series cannot contain duplicate indexes.

a)

I is False and II is True

b)

I is True and II is True

c)

I is False and II is False

d)

I is True and II is False

8.

Which of the following is correct Features of DataFrame?

a)

Potentially columns are of different types

b)

Can Perform Arithmetic operations on rows and columns

c)

Labeled axes (rows and columns)

d)

All of the above

9.

Specify the statement which can be given using row labels and column labels in order to display the sales performance in Qtr3 of year Y2016.

a)

df.at[Qtr3, Y2016]

b)

df.at['Qtr3', 'Y2016']

c)

df.iat[2,1]

d)

df.iat['Qtr3', 'Y2016']

10.

Specify the statement which can be given using row labels and column labels in order to display the sales performance in the quarters – Qtr1 and Qtr3 of years - Y2017 and Y2018.

a)

df.at[['Qtr1','Qtr3'], ['Y2017','Y2018']]

b)

df.loc[['Qtr1','Qtr3'], ['Y2017','Y2018']]

c)

df.loc['Qtr1','Qtr3', 'Y2017','Y2018']

d)

df.iloc[['Qtr1','Qtr3'], ['Y2017','Y2018']]

11.

Which point is correct in relation to 'at' and 'iat' attributes of a DataFrame object:

a)

'at' attribute uses a row label and a column label to access a particular value whereas 'iat' uses a row index and a column index to access a single value.

b)

'at' attribute uses a row index and a column index to access a particular value whereas 'iat' uses a row label and a column label to access a single value.

c)

'at' attribute uses row labels and column labels to access multiple values whereas 'iat' uses row indices and column indices to access multiple values.

d)

'at' attribute uses row indices and column indices to access multiple values whereas 'iat' uses row labels and column labels to access multiple values.

12.

Consider the DataFramedf. Identify the statement to access rows from row no.2 to end and with all columns.

a)

df.iloc[2: , :]

b)

df.iloc[2:3, 0:1]

c)

df.iloc[:,0:1]

d)

df.iloc[0:3, 0:2]

13.

Identify the function to iterate horizontally over a dataframe-

a)

access()

b)

iterrows()

c)

loc()

d)

iteritems()

14.

Write the command to import Pandas library with the name pd-

a)

import pandas as pd

b)

import panda as pd

c)

import Pandas as pd

d)

Import Pandas as pd

15.

Consider the DataFrame in question no. 5 and identify the statement to access the columns Population, Avg. Income and Per Capita Income for all rows-

a)

df.iloc[0:4, 0:4]

b)

df.loc[:, 'Population':'Per Capita Income']

c)

df.loc[:, 'Population','Avg.Income', 'Per Capita Income']

d)

df.iloc[0:3, 0,1,2]

16.

Consider the DataFrame in question no. 5 and Identify the statement to calculate the total entries in Density column-

a)

Density.count()

b)

df.Density.count()

c)

df.count('Density')

d)

df['Density'].count()

17.

Consider the DataFrame in question no. 5 and identify the statement to calculate the max value for the columns Population and Per Capita Income.

a)

df.max('Population','Per Capita Income')

b)

df.max(['Population','Per Capita Income'])

c)

df.('Population','Per Capita Income').max()

d)

df[['Population','Per Capita Income']].max()

18.

This technique rearranges the data in ascending or descending order.

a)

Sorting

b)

Grouping

c)

Pivoting

d)

Piping

19.

Select the command to change the name of city from Chennai to Madras-

a)

df.rename('Chennai'='Madras',axis=0)

b)

df.reindex(3='Madras')

c)

df.rename({'Chennai':'Madras'}, axis=0)

d)

df.rename(['Chennai':'Madras'], axis=0)

20.

Identify correct statement(s)

a)

If index is passed, then the length of the index should equal to the length of the arrays.

b)

All the ndarrays must not be of same length

c)

If no index is passed, then by default, index will be range(n), where n is the array length.

d)

1 and 3 are correct

21.

DataFrame is ______________

a)

2D list

b)

2D Array

c)

1D Array

d)

None

22.

Consider the following DataFrame. Which is the right command to delete Age column from DataFrame Name Age Department Charges Gender

a)

df.drop('Age')

b)

df.pop('Age')

c)

df.drop('Age',axis=1)

d)

b and c are correct

e)

a and b are correct

23.

df1.columns will return

a)

indexes of DataFrame

b)

Column headings of DataFrame

c)

Column index of DataFrame

d)

None of the above

24.

In X=pd.DataFrame(Y) , Y may be

a)

List, Numpy Arrays

b)

Dictionary

c)

Series, DataFrame

d)

Any of the Above

25.

The Indices of a DataFrame can be of numbers or letters or strings

a)

True

b)

False

26.

When we pass list of dictionary to create a DataFrame. The dictionary keys are by default taken as column names.

a)

True

b)

False

27.

Consider the following DataFrameDF.What the following statement is doing :- DF['Retired']=['Y','N','N','N,'N',','N','N','N']

a)

"Invalid Key " Error

b)

Will add a new blank Column

c)

Will add column Retired with specified data

d)

Will Add a new row

28.

Which is not an attribute of DataFrame Object

a)

dtype

b)

index

c)

size

d)

ndim

29.

x=pd.DataFrame() What will be the value of x after executing this code

a)

x is a dataframe which contains 0 in it

b)

x is a dataframe which contains 1 in it

c)

x is an Empty Dataframe

d)

Error

30.

after executing this code, what is x?

a)

x is a dataframe which contains 0 in it

b)

x is a dataframe which contains 1 in it

c)

x is an Empty Dataframe

d)

Error

31.

Given the dataframe. How to extract details of piyush and krati?

a)

df.iloc['piyush':'krati']

b)

df.loc['piyush':'krati']

c)

df.at['piyush':'krati']

d)

df.iat['piyush':'krati']

32.

Given the following dataframe. How to add a new column of total, which is sum of eng, hist and geog?

a)

df{'total'}=df['eng'+'hist'+'geog']

b)

df['total']=df['eng'+'hist'+'geog']

c)

df['total']=df['eng']+df['hist']+df['geog']

d)

df['total']=df['eng' : 'geog']

33.

Given the dataframe. How to see marks of hritik in the subject - english and history?

a)

df.loc['hritik','eng','hist']

b)

df.loc['hritik','eng':'hist']

c)

df.loc['hritik',['eng':'hist']]

d)

df.loc[['hritik'],['eng':'hist']]

34.

Given the following dataframe. How to extract marks of eng and geog?

a)

df['eng','geog']

b)

df[['eng'], ['geog']]

c)

df['eng' : 'geog']

d)

df[['eng','geog']]

35.

There is no difference between a NumPy array and a Series object.

a)

True

b)

False

36.

To access values using row labels you can use DF._____

a)

at

b)

loc

c)

iloc

d)

iat

37.

Given the dataframe. How to add details of a new student (name-shambhavi, marks in 3 subjects are 25, 50, 75 and total is 150)

a)

df.add('shambhavi', 25, 50, 75, 150)

b)

df.loc['shambhavi']={25, 50, 75, 150}

c)

df.loc['shambhavi']=[25, 50, 75, 150]

d)

df['shambhavi']=[25, 50, 75, 150]

38.

The axis 1 identifies a dataframe's

a)

rows

b)

columns

c)

values

d)

datatype

39.

Consider the DataFrame, namely Sdf , given below and answer any four questions out of the five (i) to (v): DataFrame: Sdf StudentID Homework Midterm Project Final 0 4560 100 97 100 95 1 5540 85 90 88 90 2 6889 92 85 88 87 3 6817 65 85 87 89 i) Which of the following commands will give the output as shown below? 5540 85 6889 92 6817 65

a)

Sdf.loc[1: , :2]

b)

Sdf.loc[0: , :2]

c)

Sdf.iloc[0: , :2]

d)

Sdf.iloc[1: , :2]

40.

Display only the first two columns of the dataframe

a)

Sdf.loc[:,:2]

b)

Sdf.loc[:,:-2]

c)

Sdf.iloc[:,:-2]

d)

Sdf.iloc[:,:2]

41.

The Principal wants to know the details of students who have scored at least 90% in the final Marks percentage. Which of the following set of commands will yield the desired result?

a)

print(Sdf['Final'>=90])

b)

print(Sdf[Sdf['Final']>=90])

c)

tmp=(Sdf[[Sdf['Final']>=90] print(tmp)

d)

print(Sdf['Final']>=90)

42.

The programmer wants to calculate how many student’s details are stored in the dataframe. Which of the following commands will yield the number of records in each column of the dataframe.

a)

Sdf.count(axis=1)

b)

pandas.count(Sdf.columns)

c)

Sdf.count()

d)

pandas.count(Sdf)

43.

What will the following statement yield? Sdf.Midterm>90

4 lines
44.

Consider the dataframe DATA as shown adjacent. Using the dataframe data, answer the following i) Which statement will delete rows with labels ‘Apple’ and ‘Lime’.

a)

DATA.drop(['Apple','Lime'])

b)

DATA.remove(['Apple','Lime'])

c)

DATA.drop(['Apple','Lime'], axis=1)

d)

DATA.remove(['Apple','Lime'], axis=1)

45.

Write statement to delete columns with labels ‘Color’ and ‘Count’.

a)

DATA.drop(['Color','Count'], axis=1)

b)

DATA.drop(['Color','Count'])

c)

DATA.drop(['Color','Count'], axis=0)

d)

DATA.drop('Color','Count', axis=1)

46.

In pandas, the function is used to check for null values in a DataFrame is _________

a)

null

b)

isnull

c)

null( )

d)

isnull( )

47.

Consider the DataFramedf and answer any four questions from (i) to (v) Name Age score 0 Raj 25 80 1 Vimal 20 90 2 Rojin 23 100 3 Mithin 28 75 4 Don 26 85 i) To change the score of Mithin to 85

a)

df.score[3]=85

b)

df[‘Mithin’][3]=85

c)

df[3]=85

d)

df[‘Mithin’]=85

48.

To display the minimum score from the DataFramedf

a)

df.min()

b)

df[min()]

c)

df [‘score’].min()

d)

df [‘score’].min

49.

To add a new column match with the values[10,8,13,23,22]

a)

df.'match'=[10,8,13,23,22]

b)

df.column=[10,8,13,23,22]

c)

df.match=[10,8,13,23,22]

d)

df['match']=[10,8,13,23,22]

50.

Which of the following command will give the column labels

a)

df.columns

b)

df.column

c)

df[column]

d)

df.columns()

51.

To get the number of elements in a dataframe, _________ attribute may be used.

a)

size

b)

shape

c)

values

d)

datatype

52.

To access values using row labels you can use DF________

a)

loc( )

b)

iloc( )

c)

at( )

d)

iat( )

53.

In Pandas the function used to delete a column in a DataFrame is

a)

remove

b)

del

c)

drop

d)

cancel

54.

Consider the following DataFramedf and answer any four questions from (i) to (v) City MaxTemp MinTemp RainFall Delhi 40 32 24.1 Bengaluru 31 25 36.2 Chennai 35 27 40.8 Mumbai 29 21 35.2 Kolkata 39 23 41.8 i) Which of the following command will display sum of every column of the data frame.

a)

print(df.sum(axis=1))

b)

print(df.sum(axis=column))

c)

print(df.sum( ).axis=1)

d)

print(df.sum( ))

55.

Which of the following command will not display maximum of column RainFall?

a)

print(df['RainFall'].max( ))

b)

print(df.RainFall.max( ))

c)

print(df.loc[:,['RainFall']].max( ))

d)

print(df.loc['RainFall'].max( ))

56.

Which of the following command will not display sum of MaxTemp, RainFall for first 5 rows?

a)

print(df.loc[0:5, ["MaxTemp","RainFall"].sum( ))

b)

print(df.loc[0:5, 1:3].sum( ))

c)

print(df.iloc[0:5, [1,3]].sum( ))

d)

print(df.iloc[0:5, [-3,-1]].sum( ))

57.

Which of the following command will display Minimum value of the MaxTemp column?

a)

df.loc['MaxTemp'].min( )

b)

df.loc.'MaxTemp'.min( )

c)

df['MaxTemp'].min( )

d)

df[:,'MaxTemp'].min( )

58.

Write down the command that will give the following output city Mumbai MaxTemp 40 MinTemp 32 RainFall 41.8 dtype:object

a)

print(df.max)

b)

print(df.max( ))

c)

print(df.max(axis=1))

d)

print(df.max, axis=1)

59.

Consider the following DataFramedf and answer any four questions from (i) to (v) import pandas as pd data = {'name': ['James', 'Anna', 'Janet', 'Yogi', 'Robin', 'Amal', 'Mohan'], 'city': ['Mexico City', 'Toronto', 'Prague', 'Shanghai','Manchester', 'Cairo', 'Osaka'], 'age': [41, 28, 33, 34, 38, 31, 37], 'score': [88.0, 79.0, 81.0, 80.0, 68.0, 61.0, 84.0]} row_labels = [101, 102, 103, 104, 105, 106, 107] df = pd.DataFrame(data=data, index=row_labels) print(df) i) Display the city of all the students.

a)

print(df['city'])

b)

print(df.city)

c)

print(df.iloc[:,1])

d)

print(df.iloc[:,0])

60.

Display the city, age and score of all the students.

a)

print(df('city','age','score'()

b)

print(df.iloc[1:4])

c)

print(df[['city','age','score']])

d)

print(df.iloc[:,1:4])

61.

Display the details of the student 103.

a)

print(df.loc[103,1])

b)

print(df.loc[103])

c)

print(df.loc[103,:])

d)

print(df.iloc[2,:])

62.

Display the details of the students 104 to 107.

a)

print(df.loc[104:107])

b)

print(df.iloc[3:])

c)

print(df.iloc[104:107])

d)

print(df.loc[3:])

63.

Display the city in which Robin lives.

a)

print(df.city[105])

b)

print(df.iloc[‘Robin’])

c)

print(df.iloc[4,1:2])

d)

print(df.city[‘Robin’])

64.

d (iv) d) Only (iv) v) Display the city in which Robin lives. i) print(df.city[105]) ii) print(df.iloc[‘Robin’]) iii) print(df.iloc[4,1:2]) iv) print(df.city[‘Robin’]) Choose the correct statement

a)

(i),(iii),(iv)

b)

Both (i) and (iii)

c)

Both(ii) and (iii)

d)

All of the above

65.

Write code statements to list the following, from a dataframe namely sales. i) List only columns ‘item’ and ‘Revenue’.

a)

print(sales[item, Revenue])

b)

print(sales[[item, Revenue]])

c)

print(sales[['item', 'Revenue']])

d)

print(sales.'item', sales.'Revenue')

66.

ii) List rows from 3 to 7.

a)

print(sales.iloc[3:7])

b)

print(sales.iloc[3:8])

c)

print(sales.loc[3:7])

d)

print(sales.loc[3:8])

67.

iii) List the value of cell in 5th row and, ‘item’ column.

a)

print(sales.loc[5,'item'])

b)

sales.iloc[5,'item'])

c)

sales.loc(5,'item')

d)

sales.iloc(5,'item')

68.

Mr. Ramesh want to rename the columns in the data frame DF itself. Which of the following attribute is useful for Mr. Ramesh?

a)

inoriginal

b)

inplace

c)

indataframe

d)

rename

69.

D1[ : ] = 77 , will set __________ values of a Data Frame 'D1' to 77.

a)

Only First Row

b)

Only First Column

c)

All

d)

None of the above

70.

In given code dataframe ‘D1’ has ________ rows and _______ columns. import pandas as pd LoD = [{‘a’:10, ‘b’:20}, {‘a’:5, ‘b’:10, ‘c’:20},{‘a’:7, ‘d’:10, ‘e’:20}] D1 = pd.DataFrame(LoD)

a)

3, 3

b)

3, 4

c)

3, 5

d)

None of the above

71.

In Pandas _______________ is used to store data in multiple columns.

a)

Series

b)

DataFrame

c)

Both of the above

d)

None of the above

72.

A _______________ is a two-dimensional labelled data structure.

a)

DataFrame

b)

Series

c)

List

d)

None of the above

73.

_____________ data Structure has both a row and column index.

a)

List

b)

Series

c)

DataFrame

d)

None of the above

74.

Which library is to be imported for creating DataFrame?

a)

Python

b)

DataFrame

c)

Pandas

d)

Random

75.

Which of the following function is used to create DataFrame?

a)

DataFrame( )

b)

NewFrame( )

c)

CreateDataFrame( )

d)

None of the Above

76.

We can create DataFrame from _____

a)

Numpy arrays

b)

List of Dictionaries

c)

Dictionary of Lists

d)

All of the above

77.

Which of the following is used to give user defined column index in DataFrame?

a)

index

b)

column

c)

columns

d)

colindex

78.

The following code create a dataframe named ‘D1’ with _______________ columns. import pandas as pd D1 = pd.DataFrame([1,2,3] )

a)

1

b)

2

c)

3

d)

4

79.

The following code create a dataframe named ‘D1’ with ___________ columns. import pandas as pd LoD = [{‘a’:10, ‘b’:20}, {‘a’:5, ‘b’:10, ‘c’:20}] D1 = pd.DataFrame(LoD)

a)

1

b)

2

c)

3

d)

4

80.

The following code create a dataframe named ‘D1’ with ______ rows. import pandas as pd LoD = [{'a':10, 'b':20}, {'a':5, 'b':10, 'c':20}] D1 = pd.DataFrame(LoD)

a)

0

b)

1

c)

2

d)

3

81.

When we create DataFrame from List of Dictionaries, then dictionary keys will become ____________

a)

Column labels

b)

Row labels

c)

Both of the above

d)

None of the above

82.

When we create DataFrame from List of Dictionaries, then number of columns in DataFrame is equal to the _______

a)

maximum number of keys in first dictionary of the list

b)

maximum number of different keys in all dictionaries of the list

c)

maximum number of dictionaries in the list

d)

None of the above

83.

When we create DataFrame from Dictionary of List then List becomes the ________________

a)

Row Labels

b)

Column Labels

c)

Values of rows

d)

None of the above

84.

When we create DataFrame from Dictionary of List then Keys becomes the _____________

a)

Row Labels

b)

Column Labels

c)

Both of the above

d)

None of the above

85.

When we create DataFrame from List of Dictionaries, then number of rows in DataFrame is equal to the ____________

a)

maximum number of keys in first dictionary of the list

b)

maximum number of keys in any dictionary of the list

c)

number of dictionaries in the list

d)

None of the above

86.

In given code dataframe ‘D1’ has ________ rows and _______ columns. import pandas as pd LoD = [{‘a’:10, ‘b’:20}, {‘a’:5, ‘b’:10, ‘c’:20},{‘a’:7, ‘d’:10, ‘e’:20}] D1 = pd.DataFrame(LoD)

a)

3, 3

b)

3, 4

c)

3, 5

d)

None of the above

87.

In given code dataframe ‘D1’ has _____ rows and ______ columns. import pandas as pd LoD = {“Name” : [“Amit”, “Anil”,”Ravi”], “RollNo” : [1,2,3]} D1 = pd.DataFrame(LoD)

a)

3, 3

b)

3, 2

c)

2, 3

d)

None of the above

88.

DataFrame created from single Series has ____ column.

a)

1

b)

2

c)

n (Where n is the number of elements in the Series)

d)

None of the above

89.

In given code dataframe ‘D1’ has _____ rows and _____ columns. import pandas as pd S1 = pd.Series([1, 2, 3, 4], index = ['a', 'b','c','d']) S2 = pd.Series([11, 22, 33, 44], index = ['a', 'bb','c','dd']) D1 = pd.DataFrame([S1,S2])

a)

2, 4

b)

4, 6

c)

4, 4

d)

2, 6

90.

In the following statement, if column ‘Rollno’ already exists in the DataFrame ‘D1’ then the assignment statement will _____________ D1['Rollno'] = [1,2,3] #There are only three rows in DataFrame D1'

a)

Return error

b)

Replace the already existing values.

c)

Add new column

d)

None of the above

91.

In DataFrame, by default new column added as the _____________ column

a)

First (Left Side)

b)

Second

c)

Last (Right Side)

d)

Random

92.

We can create a DataFrame using a single series.

a)

True

b)

False

93.

We can add a new row to a DataFrame using the _____________ method

a)

rloc[ ]

b)

iloc[ ]

c)

loc[ ]

d)

None of the above

94.

D1[ : ] = 77 , will set __________ values of a Data Frame ‘D1’ to 77.

a)

Only First Row

b)

Only First Column

c)

All

d)

None of the above

95.

In the following statement, if column ‘Rollno’ already exists in the DataFrame ‘D1’ then the assignment statement will __________ D1['Rollno'] = [1, 2] #There are only three rows in DataFrame D1'

a)

Return error

b)

Replace the already existing values.

c)

Add new column

d)

None of the above

96.

In the following statement, if column ‘Rollno’ already exists in the DataFrame ‘D1’ then the assignment statement will __________ D1['Rollno'] = 11

a)

Return error

b)

Change all values of column Roll numbers to 11

c)

Add new column

d)

None of the above

97.

DF1.loc[ ] method is used to ______ # DF1 is a DataFrame

a)

Add new row in a DataFrame ‘DF1’

b)

To change the data values of a row to a particular value

c)

Both of the above

d)

None of the above

98.

Which method is used to delete row or column in DataFrame?

a)

delete( )

b)

del( )

c)

drop( )

d)

None of the above

99.

To delete a row, the parameter axis of function drop( ) is assigned the value ______________

a)

0

b)

1

c)

2

d)

3

100.

To delete a column, the parameter axis of function drop( ) is assigned the value _____________

a)

0

b)

1

c)

2

d)

3

101.

The following statement will _________ df = df.drop(['Name', 'Class', 'Rollno'], axis = 1) #df is a DataFrame object

a)

delete three columns having labels ‘Name’, ‘Class’ and ‘Rollno’

b)

delete three rows having labels ‘Name’, ‘Class’ and ‘Rollno’

c)

delete any three columns

d)

return error

102.

If the DataFrame has more than one row with the same label, then DataFrame.drop( ) method will delete _____

a)

first matching row from it.

b)

all the matching rows from it

c)

last matching row from it.

d)

Return Error

103.

Write the code to remove duplicate row labelled as ‘R1’ from DataFrame ‘DF1’

a)

DF1 = DF1.drop(‘R1’, axis = 0)

b)

DF1 = DF1.drop(‘R1’, axis = 1)

c)

DF1 = DF1.del(‘R1’, axis = 0)

d)

DF1 = DF1.del(‘R1’, axis = 1)

104.

remove duplicate row labelled as ‘R1’ from DataFrame ‘DF1’

a)

DF1 = DF1.drop(‘R1’, axis = 0)

b)

DF1 = DF1.drop(‘R1’, axis = 1)

c)

DF1 = DF1.del(‘R1’, axis = 0)

d)

DF1 = DF1.del(‘R1’, axis = 1)

105.

Which method is used to change the labels of rows and columns in DataFrame?

a)

change( )

b)

rename( )

c)

replace( )

d)

None of the above

106.

The parameter axis=’index’ of rename( ) function is used to specify that the ________

a)

row and column label is to be changed

b)

column label is to be changed

c)

row label is to be changed

d)

None of the above

107.

What will happen if in the rename( ) function we pass only a value for a row label that does not exist?

a)

it returns an error.

b)

matching row label will not change .

c)

the existing row label will left as it is.

d)

None of the above

108.

What value should be given to axis parameter of rename function to alter column name?

a)

column

b)

columns

c)

index

d)

None of the above

109.

The following statement is __________ DF=DF.rename({‘Maths’:’Sub1′,‘Science’:’Sub2′}, axis=’index’) #DF is a DataFrame

a)

altering the row labels

b)

altering the column labels

c)

altering the row and column labels (both)

d)

Error

110.

Write a statement to delete column labelled as ‘R1’ of DataFrame ‘DF’..

a)

DF= DF.drop(‘R1’, axis=0)

b)

DF= DF.del(‘R1’, axis=0)

c)

DF= DF.drop(‘R1’, axis=0, row = ‘duplicate’)

d)

None of the above

111.

Which of the following parameter is used to specify row or column in rename function of DataFrame?

a)

rowindex

b)

colindex

c)

Both of the above

d)

index

112.

Which of the following are ways of indexing to access Data elements in a DataFrame?

a)

Label based indexing

b)

Boolean Indexing

c)

All of the above

d)

None of the above

113.

DataFrame.loc[ ] is an important method that is used for ____________ with DataFrames

a)

Label based indexing

b)

Boolean based indexing

c)

Both of the above

d)

None of the above

114.

The following statement will return the column as a _______ DF.loc[: , 'Name'] #DF is a DataFrame object

a)

DataFrame

b)

Series

c)

List

d)

Tuple

115.

We can use the ______ method to merge two DataFrames

a)

merge( )

b)

join( )

c)

append( )

d)

drop( )

116.

The following two statement will return _______________ DF.loc[:,'Name'] #DF is a DataFrame object DF['Name'] #DF is a DataFrame object

a)

Same Output

b)

Name column of DataFrame DF

c)

Both of the above

d)

Different Output

117.

The following statement will display ________ rows of DataFrame ‘DF’ print(df.loc[[True, False,True]])

a)

1

b)

2

c)

3

d)

4

118.

What we are doing in the following statement? dF1=dF1.append(dF2) #dF1 and dF2 are DataFrame object

a)

We are appending dF1 in dF2

b)

We are appending dF2 in dF1

c)

We are creating Series from DataFrame

d)

None of the above

119.

______________ parameter is used in append( ) function of DataFrame to get the column labels in sorted order.

a)

sorted

b)

sorter

c)

sort

d)

None of the above

120.

________ parameter of append( ) method may be set to True when we want to raise an error if the row labels are duplicate.

a)

verify_integrity

b)

verifyintegrity

c)

verify.integrity

d)

None of the above

121.

The ________________parameter of append() method in DataFrame may be set to True, when we do not want to use row index labels.

a)

ignore_index_val

b)

ignore_index_value

c)

ignore_index

d)

None of the above

122.

Which of the following attribute of DataFrame is used to display data type of each column in DataFrame?

a)

Dtypes

b)

DTypes

c)

dtypes

d)

datatypes

123.

The append() method of DataFrame can also be used to append ____________to a DataFrame

a)

Series

b)

Dictionary

c)

Both of the above

d)

None of the above

124.

Which of the following attribute of DataFrame is used to display row labels?

a)

columns

b)

index

c)

dtypes

d)

values

125.

Which of the following attribute of DataFrame is used to display column labels?

a)

columns

b)

index

c)

dtypes

d)

values

126.

Which of the following attribute of DataFrame display all the values from DataFrame?

a)

values

b)

Values

c)

val

d)

Val

127.

Which of the following attribute of DataFrame display the dimension of DataFrame

a)

shape

b)

size

c)

dimension

d)

values

128.

If the following statement return (5, 3) it means _____ >>>DF.shape #DF is a DataFrame object

a)

DataFrame DF has 3 rows 5 columns

b)

DataFrame DF has 5 rows 3 columns

c)

DataFrame DF has 3 rows 5 rowlabels

d)

None of the above

129.

Transpose the DataFrame means _____________

a)

Row indices and column labels of the DataFrame replace each other’s position

b)

Doubling the number of rows in DataFrame

c)

Both of the above

d)

None of the above

130.

Following statement will display ___________ rows from DataFrame ‘DF1’. >>>DF1.head()

a)

All

b)

2

c)

3

d)

5

131.

Which of the following is used to display first 2 rows of DataFrame ‘DF’?

a)

DF.head( )

b)

DF.header(2)

c)

DF.head(2)

d)

None of the above

132.

Which of the following statement is Transposing the DataFrame ‘DF1’?

a)

DF1.transpose

b)

DF1.T

c)

DF1.Trans

d)

DF1.t

133.

Which of the following function display the last ‘n’ rows from the DataFrame?

a)

head( )

b)

tail( )

c)

Tail( )

d)

None of the above

134.

We can merge/join only those DataFrames which have same number of columns.(T/F)

a)

True

b)

False

135.

Which property of dataframe is used to check that dataframe is empty or not?

a)

isempty

b)

IsEmpty

c)

empty

d)

Empty

136.

Write the output of the statement >>>df.shape , if df has the following structure. Name Class Rollno 0 Amit 6 1 1 Anil 7 2 2 Ravi 8 3

a)

(3, 4)

b)

(4, 3)

c)

(3, 3)

d)

None of the above

137.

Write the output of the statement >>>df.size , if df has the following structure: Name Class Rollno 0 Amit 6 1 1 Anil 7 2 2 Ravi 8 3

a)

9

b)

12

c)

6

d)

None of the above

138.

Parameters of read_csv( ) function is _____

a)

sep

b)

header

c)

Both of the above

d)

None of the above

139.

Which of the following function is used to load the data from the CSV file into a DataFrame?

a)

read.csv( )

b)

readcsv( )

c)

read_csv( )

d)

Read_csv( )

140.

The default value for sep parameter is _________

a)

comma

b)

semicolon

c)

space

d)

None of the above

141.

Write statement to display the row labels of ‘DF’.

a)

DF.Index

b)

DF.index( )

c)

DF.index

d)

DF.row_index

142.

Write statement to display the column labels of DataFrame ‘DF’

a)

DF.Column

b)

DF.column

c)

DF.columns

d)

DF.Columns

143.

Display first row of dataframe ‘DF’

a)

print(DF.head(1))

b)

print(DF[0 : 1])

c)

print(DF.iloc[0 : 1])

d)

All of the above

144.

Display last two rows from dataframe ‘DF’

a)

print(DF[-2 : -1])

b)

print(DF.iloc[-2 : -1])

c)

print(DF.tail(2))

d)

All of the above

145.

Write the output of the statement >>>df.empty, If df has the following structure: Name Class Rollno 0 Amit 6 1 1 Anil 7 2 2 Ravi 8 3

a)

True

b)

False

c)

Yes

d)

None of the above

146.

Write statement to display the data types of each column of dataframe ‘DF’.

a)

DF.types( )

b)

DF.dtypes

c)

DF.dtypes( )

d)

None of the above