Important QnA – Dataframe functions for IP class 12

In this article we will discuss QnA – Dataframe functions.

Objective Type Questions – dataframe functions

Click here to read the notes for the same.

Fill in the blanks:

  1. A _________function is used to display top rows (n) from dataframe.
  2. A _______ function is used to display bottom rows (n) from dataframe.
  3. _____ refers to passing True and False value as an index in Dataframes.
  4. To pass index label _________ keyword is used to in pd.dataFrame() function.
  5. By default you can display ____ no. of top/bottom rows using head()/tail() function.

Fill in the blanks Answers for dataframe functions:

  1. head()
  2. tail()
  3. ignore_index
  4. index
  5. 5 (five)
Consider this Dataframe from all questions given below

Now in the nest section we will see MCQs from the Dataframe functions topic:


1 Choose the correct function to rename city columns to location using rename() function:

a. df.rename(columns={‘City’:’Location’})

b. df.rename(columns={‘City’=’Location’})

c. df.rename(‘City’=’Location’)

d. df.rename(df.columns(‘City’,’Location’))

2 Which of the following statement(s) is/are correct with respect to df.columns properties to rename columns

  1. All columns must be specified
  2. Columns must be in the form of a list
  3. Old column names not required
  4. Columns can be specified with columns number

a Only 1 is correct

b 1, 2 and 3 are correct

c 1 and 3 are correct

d All of them are correct

3 df.index properties ca be used to

a rename rows

b rename columns

c rename rows and columns both

d None of these

4. To display 2 rows from the top in the dataframe, which of the following statement is correct:

a df.head()=2

b. df.head(n=2)

c. df.head(range(2))

d. All of the above

Error based Questions – Dataframe functions

  1. Find errors from the given code fragments:
Line 1: Dataframe Object is missingdf = pd.DataFrame({‘S.NO’:[1,2,3],’Name’:[‘Sapan’,’Vivek’,’Vishal’]})
Line 2: columns keyword is missing, and rename is a function so bracket needs to be replaced to correctdf.rename(columns={‘S.No’:’SNO’,’Name’:’Sname’})
Lines 3: index properties requires a list not in a tuple formdf.index=[1,2,3]


df.index=[1 to 3]



Application Based questions

Watch this video understand the topic and answers.

1 Consider above dataframe and rename columns using rename() function and df.columns properties.

Old column Names : City, Email, Fees

New Column Names: Location, ContactDetals, Charges


1 Using Rename Function:


2 Using columns properties:


2 Consider above dataframe and rename rows using rename() function and df.index properties.

New indexes: 1,2,3,4


1 Using rename function:


2 Using index properties:


3 Write a statement to rename rows and columns together for the dataframe.

df.rename(columns={'City':'Location','Email':'ContactDetails','Fees':'Charges'}, index={0:1,1:2,2:3,3:4})

4 Write statement to display top and botton 3 rows from dataframe.


print(df.head(3))  or   print(df.head(n=3)) 
print(df.head(3))  or   df.tail(n=3)

Click here to read topic wise notes, assignments and practical questions for class 12 IP.

Thank you reading the complete article. Share your feedback and share this article in your circle. Leave your reply about this post in comment section.

2 thoughts on “Important QnA – Dataframe functions for IP class 12”

  1. Rekha

    Plz give answers of this questions.

Comment Your Views

%d bloggers like this: