81 questions from CBSE board, sample and compartment papers (2024–2027), 1 to 5 marks, each with a model answer. Questions on creating Series and DataFrames from lists, dictionaries, NumPy arrays and scalar values, indexing and slicing with loc and iloc, head() and tail(), adding, renaming and deleting rows and columns, finding the output of Pandas code and correcting errors in it. Programming answers open in the Python Lab.
Data Handling Using Pandas – I· 1 Mark· Q10· 2024 Board Paper Python
What will be the output of the following Python code?
import pandas as pd
dd = {'One': 1, 'Two': 2, 'Three': 3, 'Seven': 7}
rr = pd.Series(dd)
rr['Four'] = 4
print(rr)
(A)(i) One 1
Two 2
Three 3
Seven 7
dtype: int64
(B)(ii) One 1
Two 2
Three 3
Four 4
Seven 7
dtype: int64
(C)(iii) Four 4
One 1
Two 2
Three 3
Seven 7
dtype: int64
(D)(iv) One 1
Two 2
Three 3
Seven 7
Four 4
dtype: int64
Model answer
(iv) One 1
Two 2
Three 3
Seven 7
Four 4
dtype: int64
Explanation: Assigning a new key to a Pandas Series appends the label 'Four' and its value 4 to the end of the Series.
Data Handling Using Pandas – I· 1 Mark· Q12· 2024 Board Paper
Which of the following command will not show first five rows from the Pandas series named S1?
(A)(i) S1[0:5]
(B)(ii) S1.head()
(C)(iii) S1.head(5)
(D)(iv) S1.head[0:5]
Model answer
(iv) S1.head[0:5]
Explanation: head is a method called with parentheses `head()`. Using square brackets `head[0:5]` results in a TypeError.
Data Handling Using Pandas – I· 1 Mark· Q18· 2024 Board Paper
Assertion (A) : A Series is a one dimensional array and a DataFrame is a two-dimensional array containing sequence of values of any data type. (int, float, list, string, etc.)
Reason (R) : Both Series and DataFrames have by default numeric indexes starting from zero.
(A)(i) Both (A) and (R) are true and (R) is the correct explanation for (A).
(B)(ii) Both (A) and (R) are true and (R) is not the correct explanation for (A).
(C)(iii) (A) is true and (R) is false.
(D)(iv) (A) is false but (R) is true.
Model answer
(ii) Both (A) and (R) are true and (R) is not the correct explanation for (A).
Explanation: Both statements are individually true, but default 0-based indexing is not the rationale for their 1D and 2D dimensionalities.
Data Handling Using Pandas – I· 2 Marks· Q20· 2024 Board Paper Python
The Python code written below has syntactical errors. Rewrite the correct code and underline the correction(s) made.
import Pandas as pd
stud=['Name' : 'Ramya', 'Class' : 11, 'House' : 'Red']
s=p.Series(s)
print(s)
Model answer
Correct Code:
import pandas as pd # 'Pandas' corrected to lowercase 'pandas'
stud = {'Name': 'Ramya', 'Class': 11, 'House': 'Red'} # Replaced [] with {}
s = pd.Series(stud) # 'p.Series(s)' corrected to 'pd.Series(stud)'
print(s)
import pandas as pd
stud = {'Name': 'Ramya', 'Class': 11, 'House': 'Red'}
s = pd.Series(stud)
print(s)
Data Handling Using Pandas – I· 2 Marks· Q22· 2024 Board Paper Python
Find the output of the following Python code :
import pandas as pd
com = pd.Series([45, 12, 15, 200], index=['mouse', 'printer', 'webcam', 'keyboard'])
print(com[1:3])
Model answer
printer 12
webcam 15
dtype: int64
Explanation: com[1:3] slices by positional index from 1 (inclusive) to 3 (exclusive), retrieving rows for 'printer' and 'webcam'.
import pandas as pd
com = pd.Series([45, 12, 15, 200], index=['mouse', 'printer', 'webcam', 'keyboard'])
print(com[1:3])
Data Handling Using Pandas – I· 2 Marks· Q24· 2024 Board Paper Python
Consider the following Python code :
import pandas as pd
S1 = pd.Series(['Rubina', 'Jaya', 'Vaibhav'], index=[10, 16, 18])
S2 = pd.Series(_________, index=[10, 16, 18])
S3 = pd.Series([56, 67, 86], _________)
xiia = {'Name': _________, 'Subject': S2, 'Marks': S3}
df = pd.DataFrame(_________)
print(df)
Complete the above Python code to display the following output :
Name Subject Marks
10 Rubina IP 56
16 Jaya HSc 67
18 Vaibhav IP 86
Data Handling Using Pandas – I· 3 Marks· Q27· 2024 Board Paper Python
Kabir, a data analyst, has stored the voter's name and age in a dictionary. Now, Kabir wants to create a list of dictionaries to store data of multiple voters. He also wants to create a DataFrame from the same list of dictionaries having appropriate row labels as shown below:
Voter_Name Voter_Age
Ar1001 Arjun 35
Ba3002 Bala 23
Go4002 Govind 25
Dh4007 Dhruv 19
Na6005 Navya 18
Help Kabir in writing a Python program to complete the task.
Data Handling Using Pandas – I· 3 Marks· Q30· 2024 Board Paper Python
Consider the given DataFrame 'password':
CodeName Category Frequency
0 aaaaaa alpha 6.91
1 dragon animal 18.52
2 baseball sport 1.29
3 football sport 11.11
4 monkey animal 3.72
5 qwerty alpha 1.85
6 abcde alpha 3.19
Write suitable Python statements for the following:
(i) To add a new row with following values:
CodeName – 'abc123'
Category – 'alphanumeric'
Frequency – 12.8
(ii) To delete the row with the row label 2.
(iii) To delete the column having column label as Frequency.
Data Handling Using Pandas – I· 4 Marks· Q32· 2024 Board Paper Python
Ms. Ritika conducted an online assessment and stored the details in a DataFrame result as given below:
Name Score Attempts Qualify
a Atulya 12.5 1 yes
b Disha 9.0 3 no
c Kavita 16.5 2 yes
d John 15.0 1 no
Answer the following questions :
(i) Predict the output of the following Python statement:
print(result.loc[:, 'Attempts'] > 1)
(ii) Write python statement to display the last three records.
(iii) Write Python statement to display records of 'a' and 'd' row labels.
OR
(Option for Part (iii) only)
(iii) Write suitable Python statement to retrieve the data stored in the file, 'registration.csv' into a DataFrame, 'regis'.
Model answer
(i) Output:
a False
b True
c True
d False
Name: Attempts, dtype: bool
(ii) result.tail(3)
(or: result.iloc[-3:] or result.loc['b':'d'])
(iii) result.loc[['a', 'd']]
OR
(iii) regis = pd.read_csv('registration.csv')
import pandas as pd
data = {
'Name': ['Atulya', 'Disha', 'Kavita', 'John'],
'Score': [12.5, 9.0, 16.5, 15.0],
'Attempts': [1, 3, 2, 1],
'Qualify': ['yes', 'no', 'yes', 'no']
}
result = pd.DataFrame(data, index=['a', 'b', 'c', 'd'])
print("(i) Output:")
print(result.loc[:, 'Attempts'] > 1)
print("\n(ii) Last three records:")
print(result.tail(3))
print("\n(iii) Records 'a' and 'd':")
print(result.loc[['a', 'd']])
Data Handling Using Pandas – I· 1 Mark· Q1· 2025 Board Paper
State whether the following statement is True or False:
In Python, we cannot create an empty DataFrame.
Model answer
False
Explanation: We can create an empty DataFrame using the function pd.DataFrame().
Data Handling Using Pandas – I· 1 Mark· Q6· 2025 Board Paper
What is the default index type for a Pandas Series if not explicitly specified?
(A)String
(B)List
(C)Numeric
(D)Boolean
Model answer
Numeric
Explanation: If no index is passed, Pandas creates a default RangeIndex starting from 0 (0, 1, 2...).
Data Handling Using Pandas – I· 1 Mark· Q9· 2025 Board Paper
Which of the following data structure is used for storing one-dimensional labelled data in Python Pandas?
(A)Integer
(B)Dictionary
(C)Series
(D)DataFrame
Model answer
Series
Explanation: Series is the 1D data structure[cite: 1233], while DataFrame is 2D.
Data Handling Using Pandas – I· 1 Mark· Q13· 2025 Board Paper Python
Which of the following Python statements will be used to select a specific element having index as points, from a Pandas Series named ser?
(A)ser.element(points)
(B)ser.select (points)
(C)ser[points]
(D)ser.show[points]
Model answer
(C) ser[points]
import pandas as pd
ser = pd.Series([10, 20, 30], index=['a', 'points', 'c'])
print(ser['points'])
Data Handling Using Pandas – I· 1 Mark· Q15· 2025 Board Paper
Which of the following libraries defines an ndarray in Python?
(A)pandas
(B)numpy
(C)matplotlib
(D)scipy
Model answer
numpy
Explanation: NumPy (Numerical Python) provides the N-dimensional array object (ndarray).
Data Handling Using Pandas – I· 1 Mark· Q17· 2025 Board Paper Python
Which of the following Python statements is used to change a column label in a DataFrame, df?
Data Handling Using Pandas – I· 1 Mark· Q18· 2025 Board Paper
In Python Pandas, DataFrame. ______ [] is used for label indexing with DataFrames.
(A)label
(B)index
(C)labindex
(D)loc
Model answer
loc
Explanation: .loc[] is used for label-based indexing, whereas .iloc[] is used for integer-based indexing.
Data Handling Using Pandas – I· 1 Mark· Q20· 2025 Board Paper
Assertion (A): The drop() method in Pandas can be used to delete rows and columns from a DataFrame.
Reason (R): The axis parameter in the drop() method specifies whether to delete rows (axis=0) or columns (axis=1).
(A)Both Assertion (A) and Reason (R) are True and Reason (R) is the correct explanation for Assertion (A).
(B)Both Assertion (A) and Reason (R) are True and Reason (R) is not the correct explanation for Assertion (A).
(C)Assertion (A) is True and Reason (R) is False.
(D)Assertion (A) is False, but Reason (R) is True.
Model answer
Both Assertion (A) and Reason (R) are True and R explains A
Explanation: drop() is used to remove labels from rows or columns, controlled by the 'axis' parameter.
Data Handling Using Pandas – I· 2 Marks· Q22· 2025 Board Paper
(a) Mention any two main points of difference between Series and DataFrame of Python Pandas.
OR
(b) Explain how we can access elements of a series using slicing. Give an example to support your answer.
Model answer
1. Series is 1-Dimensional, DataFrame is 2-Dimensional. 2. Series elements must be homogeneous, DataFrame elements can be heterogeneous.
Explanation: Fundamental structural differences in Pandas.
Data Handling Using Pandas – I· 2 Marks· Q28· 2025 Board Paper Python
(a) Rohit is trying to create a Pandas Series from scalar values. His code has some mistakes. Rewrite the correct code and underline the corrections made.
import pandas
data = [50, 15, 40]
series = pd.series(data, Index=['x', 'y', 'z'])
Print(series)
OR
(b) Complete the given Python code to generate the following output:
| COLOUR | NAME | QTY
0 | Red | Apple | 10
1 | Blue | Berry | 15
2 | Green | Guava | 20
import ________ as pd
data=[{'COLOUR':'Red','NAME':'Apple', 'QTY':10},
{'COLOUR':'Blue','NAME':'Berry', 'QTY':15},
{________,'NAME' :'Guava','QTY':20}]
df=pd.DataFrame(________)
print(________)
Data Handling Using Pandas – I· 3 Marks· Q30· 2025 Board Paper Python
(a) Write a Python program to create the following DataFrame using a Dictionary of Series:
| City | State
0 | Mumbai | Maharashtra
1 | Dehradun | Uttarakhand
2 | Bengaluru | Karnataka
3 | Hyderabad | Telangana
OR
(b) Write a Python program to create a Pandas Series as shown below from an ndarray containing the numbers 10, 20, 30, 40, 50 with corresponding indices 'A', 'B', 'C', 'D', 'E'.
A | 10
B | 20
C | 30
D | 40
E | 50
import pandas as pd
city = pd.Series(['Mumbai', 'Dehradun', 'Bengaluru', 'Hyderabad'])
state = pd.Series(['Maharashtra', 'Uttarakhand', 'Karnataka', 'Telangana'])
df = pd.DataFrame({'City': city, 'State': state})
print(df)
Data Handling Using Pandas – I· 5 Marks· Q36· 2025 Board Paper Python
Consider the DataFrame Doctor shown below:
| DID | Name | Department | Fee
0 | 101 | Dr. Joe | ENT | 1500
1 | 102 | Dr. Salma | UROLOGY | 1600
2 | 103 | Dr. Jeet | ORTHO | 1550
3 | 104 | Dr. Neha | ENT | 1200
4 | 105 | Dr. Vikram | ORTHO | 1700
Write suitable Python statements for the following:
(i) To print the last three rows of the DataFrame Doctor.
(ii) To display the names of all doctors.
(iii) To add a new column 'Discount' with value of 200 for all doctors.
(iv) To display rows with index 2 and 3.
(v) To delete the column 'Department'.
Data Handling Using Pandas – I· 1 Mark· Q14· 2026 Board Paper
In the context of creating a Pandas Series from a dictionary, which of the following statement is correct?
(A)The values of the dictionary become the indices of the Series.
(B)The keys of the dictionary become the values of the Series.
(C)The keys of the dictionary become the indices of the Series.
(D)The Series will have default integer indices starting from 0, ignoring the dictionary keys.
Model answer
The keys of the dictionary become the indices of the Series.
Explanation: When making a Series from a dict, Pandas automatically maps the dictionary keys to the Series indexes and the dictionary values to the Series values.
Data Handling Using Pandas – I· 1 Mark· Q15· 2026 Board Paper
In Pandas, when extracting a portion of a Series ser1 using ser1[start:end] with positional indices start and end, which of the following statements is true?
(A)The element at the end index is included in the output.
(B)The element at the end index is excluded from the output.
(C)The elements at both the start and end indices are excluded from the output.
(D)The element at the start index is excluded from the output.
Model answer
The element at the end index is excluded from the output.
Explanation: In standard Python and Pandas positional slicing, the upper bound ('end' index) is exclusive.
Data Handling Using Pandas – I· 1 Mark· Q18· 2026 Board Paper
In a Pandas DataFrame, which value for axis will be used to delete a column?
(A)axis = -1
(B)axis = 0
(C)axis = 1
(D)axis = 2
Model answer
axis = 1
Explanation: In Pandas, axis=0 refers to rows, and axis=1 refers to columns.
Data Handling Using Pandas – I· 1 Mark· Q20· 2026 Board Paper
Assertion (A): Pandas DataFrame can store values of multiple data types in multiple Columns.
Reason (R): DataFrames are implemented using 2D arrays, which allows only numeric values.
Model answer
(A) is True, but (R) is False.
Explanation: DataFrames can hold heterogeneous data (mix of int, float, string) across different columns. The reason is false because DataFrames do not restrict data to only numeric values.
Data Handling Using Pandas – I· 2 Marks· Q22· 2026 Board Paper Python
(a) List any two characteristics of Pandas library in Python.
OR
(b) Briefly explain the purpose of Boolean Indexing with respect to DataFrames. Support your answer with a suitable example.
Model answer
(a) Characteristics of Pandas: Works with tabular data (DataFrames and Series), Easy data handling, Powerful data analysis (filtering, sorting), Handles missing data, Fast and efficient.
OR
(b) Boolean Indexing is used to filter and extract specific rows from a DataFrame based on given condition(s). It returns only those rows where the condition is True.
# Example for Boolean Indexing
import pandas as pd
df = pd.DataFrame({'Name': ['Ajay', 'Riya', 'David'], 'Age': [25, 30, 35]})
condition = df['Age'] > 30
print(df[condition])
Data Handling Using Pandas – I· 2 Marks· Q28· 2026 Board Paper Python
(a) Niharika wants to create a Pandas Series using a NumPy array with three elements 'a', 'b', and 'c', and assign custom indexes 'first', 'second' and 'third'. Help her complete the code below.
import pandas as pd
import ______ as np
arr = np._____ (['a' , 'b' , 'c'])
s = pd._____(arr,_____=['first','second','third'])
print(s)
OR
(b) Write the output of the following code:
import pandas as pd
s1 = pd.Series ([1, 2, 3], index = ['a','b','c'])
s2 = pd.Series ([4, 5, 6], index = ['b','c','d'])
print (s1 + s2)
Model answer
(a) Blanks to complete the code:
1. numpy
2. array
3. Series
4. index
Completed code:
import pandas as pd
import numpy as np
arr = np.array(['a', 'b', 'c'])
s = pd.Series(arr, index=['first','second','third'])
print(s)
OR
(b) Output of s1 + s2:
a NaN
b 5.0
c 8.0
d NaN
dtype: float64
# Part (a)
import pandas as pd
import numpy as np
arr = np.array(['a', 'b', 'c'])
s = pd.Series(arr, index=['first','second','third'])
print("--- Part (a) Series ---")
print(s)
# Part (b)
s1 = pd.Series([1, 2, 3], index=['a','b','c'])
s2 = pd.Series([4, 5, 6], index=['b','c','d'])
print("\n--- Part (b) Addition ---")
print(s1 + s2)
Data Handling Using Pandas – I· 3 Marks· Q30· 2026 Board Paper Python
(a) Write a Python program to create and display a Pandas Series as shown below:
July 31
Aug 31
Sept 30
Oct 31
The index labels are the names of the months - July, Aug, Sept, Oct.
The corresponding scalar values are the number of days in these respective months - 31, 31, 30, 31.
OR
(b) A CSV file named customer.csv contains records of customers. The first row of the file represents the header. Sample data from the file is shown below:
Name, Age, City
Rudra,17,Kolkata
Divya,19,Dehradun
Nabeel,22,Lucknow
Write a Python program to import data from the CSV file into a Pandas DataFrame named DF and display the last two rows.
Model answer
(a) Code to create Series:
import pandas as pd
days = [31, 31, 30, 31]
months = ['July', 'Aug', 'Sept', 'Oct']
s = pd.Series(days, index=months)
print(s)
OR
(b) Code to import CSV and show last 2 rows:
import pandas as pd
DF = pd.read_csv('customer.csv')
print(DF.tail(2))
# Part (a)
import pandas as pd
days = [31, 31, 30, 31]
months = ['July', 'Aug', 'Sept', 'Oct']
s = pd.Series(days, index=months)
print("--- Part (a) output ---")
print(s)
# Part (b) mock setup
import io
csv_data = """Name,Age,City
Rudra,17,Kolkata
Divya,19,Dehradun
Nabeel,22,Lucknow"""
DF = pd.read_csv(io.StringIO(csv_data))
print("\n--- Part (b) output (last 2 rows) ---")
print(DF.tail(2))
Data Handling Using Pandas – I· 5 Marks· Q36· 2026 Board Paper Python
Consider the DataFrame 'Scholarship'. Answer the following:
I. Write Python code to create and display the given DataFrame using the Dictionary of Series method.
II. Rename row indexes to ['a', 'b', 'c', 'd', 'e'].
III. Write a Python statement to remove the last row of the given DataFrame.
import pandas as pd
# I. Creation
name = pd.Series(["Ananya", "Karan", "Simran", "Rahul", "Priya"])
course = pd.Series(["B.Sc.", "B.Tech", "MCA", "BCA", "BA"])
amount = pd.Series([62000, 67000, 64000, 70000, 69000])
data = {"Name": name, "Course": course, "Amount": amount}
Scholarship = pd.DataFrame(data)
print("Original DataFrame:\n", Scholarship)
# II. Rename Index
Scholarship.index = ['a', 'b', 'c', 'd', 'e']
print("\nAfter Renaming Index:\n", Scholarship)
# III. Remove last row
Scholarship = Scholarship.drop(Scholarship.index[-1])
print("\nAfter Removing Last Row:\n", Scholarship)
Data Handling Using Pandas – I· 1 Mark· Q1· 2025 Compartment Paper
State whether the following statement is True or False:
"Series data structure of Pandas can hold the value of integer data type only."
Model answer
False
Explanation: A Pandas Series can hold data of any type (integer, string, float, python objects, etc.).
Data Handling Using Pandas – I· 1 Mark· Q6· 2025 Compartment Paper
Which of the following functions is used to delete a row from a DataFrame?
(A)drop()
(B)delete()
(C)remove_row()
(D)pop_attribute()
Model answer
drop()
Explanation: The drop() function is used in Pandas to drop specified labels from rows (axis=0) or columns (axis=1).
Data Handling Using Pandas – I· 1 Mark· Q7· 2025 Compartment Paper
_____ is the type of indexing that allows us to filter a DataFrame by applying a condition.
(Label Indexing / Boolean Indexing)
Model answer
Boolean Indexing
Explanation: Boolean indexing uses boolean vectors (True/False) to filter the data.
Data Handling Using Pandas – I· 1 Mark· Q13· 2025 Compartment Paper
NumPy stands for _____ Python.
(A)Numerous
(B)Neural
(C)Numerical
(D)Numron
Model answer
Numerical
Explanation: NumPy is short for Numerical Python, a library used for working with arrays and mathematical operations.
Data Handling Using Pandas – I· 1 Mark· Q15· 2025 Compartment Paper Python
To create a Pandas series from an ndarray 'array1', which of the following statements can be used? (Note: Assume pd as alias for pandas)
(A)pd.array(array1)
(B)nd.series(array1)
(C)pd.Series(array1)
(D)array1.toSeries()
Model answer
pd.Series(array1)
import pandas as pd
import numpy as np
array1 = np.array([1, 2, 3])
s = pd.Series(array1)
print(s)
Data Handling Using Pandas – I· 1 Mark· Q18· 2025 Compartment Paper Python
How can we add a new column named 'name' to a DataFrame 'dF'? (Note: Assume the values for the column are stored in a list named 'data')
(A)dF.add_column(name, data)
(B)dF['name'] = data
(C)dF.set_column(name, data)
(D)dF.add(name, data)
Model answer
dF['name'] = data
import pandas as pd
dF = pd.DataFrame({'ID': [1, 2]})
data = ['Alice', 'Bob']
dF['name'] = data
print(dF)
Data Handling Using Pandas – I· 1 Mark· Q20· 2025 Compartment Paper
Assertion (A): Pandas is a high level data manipulation tool used for analyzing data.
Reason (R): It is very easy to import and export data using the Pandas library which has a very rich set of functions.
Model answer
Both Assertion (A) and Reason (R) are True and Reason (R) is the correct explanation for Assertion (A).
Explanation: Pandas is indeed built for data manipulation and its easy IO operations (like read_csv, to_sql) are part of why it is considered a high-level manipulation tool.
Data Handling Using Pandas – I· 2 Marks· Q22· 2025 Compartment Paper
(a) What is DataFrame in Pandas? Explain with the help of an example.
OR
(b) What is data visualization? Also mention its any one main purpose.
Model answer
(a) A DataFrame is a two-dimensional labelled data structure in Pandas in which data is organized into rows and columns.
OR
(b) Data Visualization is the graphical representation of data using charts, graphs, and maps. Purpose: To help people understand and interpret data easily.
Explanation: DataFrame acts like a spreadsheet or SQL table. Visualization makes complex data accessible.
Data Handling Using Pandas – I· 3 Marks· Q30· 2025 Compartment Paper Python
(a) Write a Python Program to create a DataFrame using a list of dictionaries with the following data:
Student | Marks
0 | Aarav | 85
1 | Aisha | 90
2 | Vivaan | 78
3 | Meera | 92
OR
(b) Write a Python program to create a Pandas Series from a scalar value. The Series should have indexes as 'X1', 'X2', 'X3', 'X4', 'X5' with each value in the Series set to 100.
Model answer
(a) Code using list of dicts:
import pandas as pd
data = [
{'Student': 'Aarav', 'Marks': 85},
{'Student': 'Aisha', 'Marks': 90},
{'Student': 'Vivaan', 'Marks': 78},
{'Student': 'Meera', 'Marks': 92}
]
df = pd.DataFrame(data)
print(df)
OR
(b) Code using scalar value:
import pandas as pd
s = pd.Series(100, index=['X1', 'X2', 'X3', 'X4', 'X5'])
print(s)
import pandas as pd
# Part A
data = [
{'Student': 'Aarav', 'Marks': 85},
{'Student': 'Aisha', 'Marks': 90},
{'Student': 'Vivaan', 'Marks': 78},
{'Student': 'Meera', 'Marks': 92}
]
df = pd.DataFrame(data)
print(df)
# Part B
s = pd.Series(100, index=['X1', 'X2', 'X3', 'X4', 'X5'])
print(s)
Data Handling Using Pandas – I· 5 Marks· Q36· 2025 Compartment Paper Python
Consider the DataFrame dF shown below:
PRODUCT_ID | PRODUCT_NAME | CATEGORY | PRICE
P001 | Laptop | Electronics | 60000
...
Write Python statements for the DataFrame dF to:
(i) Print the first row of the DataFrame dF.
(ii) Display the 'PRODUCT_NAME' column for all products.
(iii) Add a new row with the following values: [5, 'P006', 'AC', 'HOME', 80000]
(iv) Remove the column 'CATEGORY'.
(v) Rename the column 'PRODUCT_NAME' to 'Item'.
Data Handling Using Pandas – I· 1 Mark· Q10· 2024 Sample Paper
Which of the following command will show the last 3 rows from a Pandas Series named NP?
(A)i. NP.Tail( )
(B)ii. NP.tail(3)
(C)iii. NP.TAIL(3)
(D)iv. All of the above
Model answer
ii. NP.tail(3)
Explanation: Python is case-sensitive, so the method name is lowercase `tail(3)`.
Data Handling Using Pandas – I· 1 Mark· Q12· 2024 Sample Paper
In Python Pandas, while performing mathematical operations on series, index matching is implemented and all missing values are filled in with _____by default.
(A)i. Null
(B)ii. Blank
(C)iii. NaN
(D)iv. Zero
Model answer
iii. NaN
Explanation: Pandas automatically aligns series indices; missing matching labels are populated with NaN (Not a Number).
Data Handling Using Pandas – I· 1 Mark· Q18· 2024 Sample Paper
Assertion (A):- To use the Pandas library in a Python program, one must import it.
Reasoning (R): - The only alias name that can be used with the Pandas library is pd.
(A)i. Both A and R are true and R is the correct explanation for A
(B)ii. Both A and R are true and R is not the correct explanation for A
(C)iii. A is True but R is False
(D)iv. A is false but R is True
Model answer
iii. A is True but R is False
Explanation: Assertion A is true (external libraries must be imported), but Reasoning R is false because any valid identifier can be chosen as an alias (e.g. `import pandas as p`).
Data Handling Using Pandas – I· 2 Marks· Q20· 2024 Sample Paper Python
The python code written below has syntactical errors. Rewrite the correct code and underline the corrections made.
Import pandas as pd
df ={"Technology":["Programming","Robotics","3D Printing"],"Time(in months)":[4,4,3]}
df= Pd.dataframe(df)
Print(df)
Model answer
import pandas as pd
df ={"Technology":["Programming","Robotics","3D Printing"],"Time (in months)":[4,4,3]}
df= pd.DataFrame(df)
print(df)
import pandas as pd
df ={"Technology":["Programming","Robotics","3D Printing"],"Time (in months)":[4,4,3]}
df= pd.DataFrame(df)
print(df)
Data Handling Using Pandas – I· 2 Marks· Q22· 2024 Sample Paper Python
Predict the output of the given Python code:
import pandas as pd
list1=[-10,-20,-30]
ser = pd.Series(list1*2)
print(ser)
Model answer
0 -10
1 -20
2 -30
3 -10
4 -20
5 -30
dtype: int64
import pandas as pd
list1=[-10,-20,-30]
ser = pd.Series(list1*2)
print(ser)
Data Handling Using Pandas – I· 2 Marks· Q24· 2024 Sample Paper Python
Complete the given Python code to get the required output as: Rajasthan
import _________ as pd
di = {'Corbett': 'Uttarakhand', 'Sariska': 'Rajasthan', 'Kanha': 'Madhya Pradesh', 'Gir':'Gujarat'}
NP = ___________. Series( _____ )
print(NP[ ___________ ])
Model answer
import pandas as pd
di = {'Corbett': 'Uttarakhand', 'Sariska':'Rajasthan', 'Kanha': 'Madhya Pradesh','Gir':'Gujarat'}
NP = pd.Series( di)
print(NP[ 'Sariska'])
import pandas as pd
di = {'Corbett': 'Uttarakhand', 'Sariska':'Rajasthan', 'Kanha': 'Madhya Pradesh','Gir':'Gujarat'}
NP = pd.Series( di)
print(NP[ 'Sariska'])
Data Handling Using Pandas – I· 3 Marks· Q27· 2024 Sample Paper Python
Create a DataFrame in Python from the given list:
[[‘Divya’,’HR’,95000],[‘Mamta’,’Marketing’,97000],[‘Payal’,’IT’,980000],
[‘Deepak’,’Sales’,79000]]
Also give appropriate column headings as shown below:
Name Department Salary
0 Divya HR 95000
1 Mamta Marketing 97000
2 Payal IT 980000
3 Deepak Sales 79000
import pandas as pd
df=[["Divya","HR",95000],["Mamta","Marketing",97000],["Payal","IT",980000], ["Deepak","Sales",79000]]
df=pd.DataFrame(df,columns=["Name","Department","Salary"])
print(df)
Data Handling Using Pandas – I· 3 Marks· Q30· 2024 Sample Paper Python
Consider the given DataFrame ‘Genre’:
Type Code
0 Fiction F
1 Non Fiction NF
2 Drama D
3 Poetry P
Write suitable Python statements for the following:
i. Add a column called Num_Copies with the following data:
[300,290,450,760].
ii. Add a new genre of type ‘Folk Tale' having code as “FT” and 600 number of copies.
iii. Rename the column ‘Code’ to ‘Book_Code’.
Model answer
i. Genre["Num_Copies"]=[300,290,450,760]
ii. Genre.loc[4]=["Folk Tale","FT",600]
iii. Genre=Genre.rename({"Code":"Book_Code"}, axis=1)
OR
Genre=Genre.rename({"Code":"Book_Code"}, axis="columns")
Data Handling Using Pandas – I· 4 Marks· Q32· 2024 Sample Paper Python
Ekam, a Data Analyst with a multinational brand has designed the DataFrame df that contains the four quarter’s sales data of different stores as shown below:
Store Qtr1 Qtr2 Qtr3 Qtr4
0 Store1 300 240 450 230
1 Store2 350 340 403 210
2 Store3 250 180 145 160
Answer the following questions:
i. Predict the output of the following python statement:
a. print(df.size)
b. print(df[1:3])
ii. Delete the last row from the DataFrame.
iii. Write Python statement to add a new column Total_Sales which is the addition of all the 4 quarter sales.
OR
(Option for part iii only)
Write Python statement to export the DataFrame to a CSV file named data.csv stored at D: drive.
Model answer
i.
a. 15
b.
Store Qtr1 Qtr2 Qtr3 Qtr4
1 Store2 350 340 403 210
2 Store3 250 180 145 160
ii.
df=df.drop(2)
OR
df.drop(2,axis=0)
iii.
df["total"]=df["Qtr1"]+df["Qtr2"]+df["Qtr3"]+df["Qtr4"]
OR
df.to_csv("D:\\data.csv")
Data Handling Using Pandas – I· 1 Mark· Q13· 2025 Sample Paper
In a Pandas DataFrame, if the tail() function is used without specifying the optional argument indicating the number of rows to display, what is the default number of rows displayed, considering the DataFrame has 10 entries?
(A)0
(B)1
(C)4
(D)5
Model answer
(D) 5
Explanation: Both head() and tail() return 5 rows by default.
Data Handling Using Pandas – I· 1 Mark· Q15· 2025 Sample Paper Python
While creating a Series using a dictionary, the keys of the dictionary become:
(A)Values of the Series
(B)Indices of the Series
(C)Data type of the Series
(D)Name of the Series
Model answer
(B) Indices of the Series
import pandas as pd
d = {'a': 1, 'b': 2}
s = pd.Series(d)
print(s.index)
Data Handling Using Pandas – I· 1 Mark· Q17· 2025 Sample Paper
Fill in the Blank Boolean indexing in Pandas DataFrame can be used for _______.
(A)Creating a new DataFrame
(B)Sorting data based on index labels
(C)Joining data using labels
(D)Filtering data based on condition
Model answer
(D) Filtering data based on condition
Explanation: Boolean indexing allows selecting rows where a condition is True.
Data Handling Using Pandas – I· 1 Mark· Q20· 2025 Sample Paper
Assertion (A): We can add a new column in an existing DataFrame.
Reason (R): DataFrames are size mutable.
(A)Both Assertion (A) and Reason (R) are true, and Reason (R) is the correct explanation of Assertion (A)
(B)Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A)
(C)Assertion (A) is True, but Reason (R) is False
(D)Assertion (A) is False, but Reason (R) is True
Model answer
(A) Both A and R are true, and R is the correct explanation of A
Explanation: DataFrames can grow or shrink in size (columns/rows can be added/dropped).
Data Handling Using Pandas – I· 2 Marks· Q22· 2025 Sample Paper
(A) What is a Series in Python Pandas? Also, give a suitable example to support your answer.
OR
(B) What does the term 'library' signify in Python? Mention one use for each of the following libraries: • Pandas • Matplotlib
Model answer
Series: 1D array with labeled axis. Example: s = pd.Series([10,20]). Library: Collection of modules. Pandas for data analysis, Matplotlib for plotting.
Explanation: Series is the basic building block of Pandas.
Data Handling Using Pandas – I· 2 Marks· Q28· 2025 Sample Paper Python
(A) Sneha is writing a Python program to create a DataFrame using a list of dictionaries. However, her code contains some mistakes. Identify the errors, rewrite the correct code, and underline the corrections made.
import Pandas as pd
D1 = {'Name': 'Rakshit', 'Age': 25}
D2 = {'Name': 'Paul', 'Age': 30}
D3 = {'Name': 'Ayesha", 'Age': 28}
data = [D1,D2,D3)
df = pd.Dataframe(data)
print(df)
OR
(B) Complete the given Python code to get the required output (ignore the dtype attribute).
Output:
Tamil Nadu Chennai
Uttar Pradesh Lucknow
Manipur Imphal
Code:
import _______ as pd
data = ['Chennai','_______','Imphal']
indx = ['Tamil Nadu','Uttar Pradesh','Manipur']
s = pd.Series(_______, indx)
print(_______)
Data Handling Using Pandas – I· 3 Marks· Q30· 2025 Sample Paper Python
(A) Write a Python program to create the following DataFrame using a list of dictionaries.
| Product | Price
0 | Laptop | 60000
1 | Desktop | 45000
2 | Monitor | 15000
3 | Tablet | 30000
OR
(B) Write a Python Program to create a Pandas Series as shown below using a dictionary. Note that the left column indicates the indices and the right column displays the data.
Russia | Moscow
Hungary | Budapest
Switzerland | Bern
import pandas as pd
# (A)
data = [
{'Product': 'Laptop', 'Price': 60000},
{'Product': 'Desktop', 'Price': 45000},
{'Product': 'Monitor', 'Price': 15000},
{'Product': 'Tablet', 'Price': 30000}
]
df = pd.DataFrame(data)
print("--- DataFrame ---")
print(df)
# (B)
countries = {'Russia': 'Moscow', 'Hungary': 'Budapest', 'Switzerland': 'Bern'}
s = pd.Series(countries)
print("\n--- Series ---")
print(s)
Data Handling Using Pandas – I· 5 Marks· Q36· 2025 Sample Paper Python
Consider the DataFrame df shown below.
MovieID Title | Year | Rating
0 | 1 | LAGAAN | 2001 | 8.4
1 | 2 | TAARE ZAMEEN PAR | 2007 | 8.5
2 | 3 | 3 IDIOTS | 2009 | 8.4
3 | 4 | DANGAL | 2016 | 8.4
4 | 5 | ANDHADHUN | 2018 | 8.3
Write Python statements for the DataFrame df to:
I. Print the first two rows of the DataFrame df.
II. Display titles of all the movies.
III. Remove the column rating.
IV. Display the data of the 'Title' column from indexes 2 to 4 (both included)
V. Rename the column name 'Title' to 'Name'.
Data Handling Using Pandas – I· 1 Mark· Q1· 2026 Sample Paper
State whether the following statement is True or False:
The drop() method can be used to remove rows or columns from a Pandas DataFrame.
Model answer
True
Explanation: The drop() method removes rows or columns by specifying the label and axis (0 for rows, 1 for columns).
Data Handling Using Pandas – I· 1 Mark· Q8· 2026 Sample Paper
The default index used in a Pandas Series, if no index is explicitly specified, is _____
(A)Strings starting with 'a'
(B)Consecutive integers starting from
(C)Random integers
(D)Consecutive integers starting from 0
Model answer
Consecutive integers starting from 0
Explanation: Pandas automatically assigns a RangeIndex (0, 1, 2, ...) if no index is provided.
Data Handling Using Pandas – I· 1 Mark· Q12· 2026 Sample Paper
When two Pandas Series with different indices are added, the result is _____.
(A)Error occurs
(B)Indices are ignored, and elements are added in order
(C)The result has all indices, with missing values filled as NaN
(D)Only the common indices are retained in the result
Model answer
The result has all indices, with missing values filled as NaN
Explanation: Pandas performs data alignment. Indices not present in both Series result in NaN (Not a Number).
Data Handling Using Pandas – I· 1 Mark· Q15· 2026 Sample Paper
Which of the following Python commands selects the first 3 rows of a DataFrame df, assuming that labelled index are consecutive integers starting from 0?
(A)df.loc[:3]
(B)df.loc[:2]
(C)df.loc[0:4]
(D)df.loc[1:4]
Model answer
df.loc[:2]
Explanation: .loc is label-inclusive. Since indices start at 0, .loc[:2] selects indices 0, 1, and 2 (total 3 rows).
Data Handling Using Pandas – I· 1 Mark· Q18· 2026 Sample Paper Python
Which of the following Python statements creates an empty Pandas DataFrame (Note: pd is an alias for pandas)?
(A)pd.DataFrame(None)
(B)pd.DataFrame()
(C)pd.DataFrame([])
(D)pd.DataFrame.empty()
Model answer
pd.DataFrame()
import pandas as pd
df = pd.DataFrame()
print(df)
Data Handling Using Pandas – I· 1 Mark· Q20· 2026 Sample Paper
Assertion (A):. The output of print(df) and print(df.loc[:]) will be same for a DataFrame df.
Reason (R): The statement print(df.loc[:]) will display all rows and columns of the DataFrame df, thus showing the entire data.
(A)Both A and R are True, and R correctly explains A.
(B)Both A and R are True, but R does not correctly explain A.
(C)A is True, but R is False.
(D)A is False, but R is True.
Model answer
Both A and R are True, and R correctly explains A
Explanation: df.loc[:] selects all rows using the slicing operator, effectively displaying the whole DataFrame.
Data Handling Using Pandas – I· 2 Marks· Q22· 2026 Sample Paper
(A) What is a DataFrame in Pandas? Mention any one property of DataFrame.
OR
(B) List any two differences between Series and DataFrame in Pandas.
Model answer
DataFrame is a 2D labeled data structure. Property: Size-mutable. Difference: Series is 1D/Homogeneous, DataFrame is 2D/Heterogeneous.
Explanation: DataFrames are like spreadsheet tables.
Data Handling Using Pandas – I· 2 Marks· Q24· 2026 Sample Paper Python
Ravi wants to create a Pandas Series as shown below:
January | 31
February | 28
March | 31
Help him in completing the code below to achieve the desired output. Note: ser_data is a dictionary.
import _____ as pd
ser_data = _____
s = pd._____(ser_data)
print(s)
import pandas as pd
ser_data = {'January': 31, 'February': 28, 'March': 31}
# s = pd.Series(ser_data)
s = pd.Series(ser_data)
print(s)
Data Handling Using Pandas – I· 2 Marks· Q28· 2026 Sample Paper Python
(A) Write the output of the following code:
import pandas as pd
students = pd.Series(['Abhay', 'Ananya', 'Javed'])
marks = pd.Series([85, 92, 88])
data = {'Name': students, 'Marks': marks}
df = pd.DataFrame(data)
df.rename(columns={'Name': 'StuName', 'Marks': 'Score'}, inplace=True)
print(df)
OR
(B) Write the output of the following code:
import pandas as pd
states = pd.Series(['Maharashtra', 'Gujarat', 'Kerala'])
capitals = pd.Series(['Mumbai', 'Gandhinagar', 'Thiruvananthapuram'])
data = {'State': states, 'Capital': capitals}
df = pd.DataFrame(data)
df.drop(index=1, inplace=True)
print(df)
import pandas as pd
# Part A
students = pd.Series(['Abhay', 'Ananya', 'Javed'])
marks = pd.Series([85, 92, 88])
data = {'Name': students, 'Marks': marks}
df = pd.DataFrame(data)
df.rename(columns={'Name': 'StuName', 'Marks': 'Score'}, inplace=True)
print("--- Output A ---")
print(df)
# Part B
states = pd.Series(['Maharashtra', 'Gujarat', 'Kerala'])
capitals = pd.Series(['Mumbai', 'Gandhinagar', 'Thiruvananthapuram'])
data_b = {'State': states, 'Capital': capitals}
df_b = pd.DataFrame(data_b)
df_b.drop(index=1, inplace=True)
print("\n--- Output B ---")
print(df_b)
Data Handling Using Pandas – I· 3 Marks· Q30· 2026 Sample Paper Python
(A) Write a Python program to create a Pandas Series as shown below using a ndarray, where the subject names are the indices and the corresponding marks are the values in the series.
Mathematics | 85
Science | 90
English | 78
History | 88
OR
(B) Write a Python program to create the Pandas DataFrame displayed below using a list of dictionaries.
| Course | Duration
0 | Data Science | 12
1 | Artificial Intelligence | 18
2 | Web Development | 6
import pandas as pd
import numpy as np
# Part A
marks_arr = np.array([85, 90, 78, 88])
subjects = ['Mathematics', 'Science', 'English', 'History']
ser = pd.Series(marks_arr, index=subjects)
print("--- Series ---")
print(ser)
# Part B
data = [
{'Course': 'Data Science', 'Duration': 12},
{'Course': 'Artificial Intelligence', 'Duration': 18},
{'Course': 'Web Development', 'Duration': 6}
]
df = pd.DataFrame(data)
print("\n--- DataFrame ---")
print(df)
Data Handling Using Pandas – I· 5 Marks· Q36· 2026 Sample Paper Python
Consider the DataFrame df shown below.
| Name | Department | Salary
0 | Rohan Sharma | IT | 75000
1 | Meera Kapoor | HR | 68000
2 | Aarav Singh | Finance | 85000
3 | Nisha Singh | Marketing | 72000
4 | Aditya Verma | IT | 80000
Write Python statements for the following tasks:
I. Print the last three rows of the DataFrame df.
II. Add a new column named "Experience" with values [5, 8, 10, 6, 7].
III. Delete the column "Salary" from the DataFrame.
IV. Rename the column "Department" to "Dept".
V. Display only the "Name" and "Salary" columns from the DataFrame.
import pandas as pd
data = {
'Name': ['Rohan Sharma', 'Meera Kapoor', 'Aarav Singh', 'Nisha Singh', 'Aditya Verma'],
'Department': ['IT', 'HR', 'Finance', 'Marketing', 'IT'],
'Salary': [75000, 68000, 85000, 72000, 80000]
}
df = pd.DataFrame(data)
# 1. Last 3 rows
print(df.tail(3))
# 2. Add Experience
df['Experience'] = [5, 8, 10, 6, 7]
# 3. Drop Salary
df.drop(columns=['Salary'], inplace=True)
# 4. Rename Department
df.rename(columns={'Department': 'Dept'}, inplace=True)
# 5. Display Name and Salary (Note: Salary was dropped, so re-creating for demo)
df['Salary'] = [75000, 68000, 85000, 72000, 80000]
print(df[['Name', 'Salary']])
Data Handling Using Pandas – I· 1 Mark· Q1· 2027 Sample Paper
A Pandas Series S1 is created with index labels ['a', 'b', 'c', 'd', 'e']. State whether the following statement is True or False:
"The statement S1['b':'d'] will produce the same result as S1[1:3]."
Model answer
False
Data Handling Using Pandas – I· 1 Mark· Q8· 2027 Sample Paper Python
What will be the output of the following code?
import pandas as pd
print(pd.Series(5, index=[0, 1, 2]))
(A)A Series with values 5, 5, 5
(B)A Series with value 5 only at index 0
(C)A Series with values 0, 1, 2
(D)Error
Model answer
A. A Series with values 5, 5, 5
import pandas as pd
print(pd.Series(5, index=[0, 1, 2]))
Data Handling Using Pandas – I· 1 Mark· Q12· 2027 Sample Paper
If we add two Pandas Series that do not have matching index labels, the result for those non-matching indices will be:
(A)0
(B)Error
(C)NaN
(D)Empty string
Model answer
C. NaN
Data Handling Using Pandas – I· 1 Mark· Q18· 2027 Sample Paper
When creating a DataFrame from a list of dictionaries, the dictionary keys become:
(A)Row indices
(B)Data values
(C)Column labels
(D)Positional Index
Model answer
C. Column labels
Data Handling Using Pandas – I· 1 Mark· Q20· 2027 Sample Paper
Assertion (A) The statement df.drop('Science', axis=0) will remove the column labeled 'Science' from the DataFrame.
Reason (R) In Pandas drop() method, axis=0 refers to row-wise operations and axis=1 refers to column-wise operations.
(A)Both Assertion (A) and Reason (R) are True and Reason (R) is the correct explanation for Assertion (A).
(B)Both Assertion (A) and Reason (R) are True and Reason (R) is not the correct explanation for Assertion (A).
(C)Assertion (A) is True and Reason (R) is False.
(D)Assertion (A) is False, but Reason (R) is True.
Model answer
D. Assertion (A) is False, but Reason (R) is True.
Data Handling Using Pandas – I· 2 Marks· Q22· 2027 Sample Paper Python
(A) (i) Explain the use of the head() function in a Pandas DataFrame.
(ii) What happens if the parameter n is not specified in the head() function?
OR
(B) Explain the concept of Boolean Indexing in DataFrames. Write a small Python code example to demonstrate it.
Model answer
(A) (i)
The head() function displays the first n rows of a DataFrame.
(ii)
If n is not specified in head(), it returns the first 5 rows by default.
OR
(B) Boolean indexing is a technique used to select subsets of data based on the actual values in the DataFrame rather than row/column labels.
Example
import pandas as pd
data = [
{'Name': 'Aarav', 'Age': 24},
{'Name': 'Priya', 'Age': 30}
]
df = pd.DataFrame(data)
print(df['Age'] > 25)
Output
0 False
1 True
Data Handling Using Pandas – I· 2 Marks· Q28· 2027 Sample Paper Python
(A) Consider the following two dictionaries:
dict1 = {'a': 10, 'b': 20}
dict2 = {'a': 5, 'b': 10, 'c': 20}
Write Python code to create a DataFrame from a list containing the above two dictionaries.
OR
(B) Mention the purpose of read_csv() and explain the use of its sep parameter.
Model answer
(A)
import pandas as pd
dict1 = {'a': 10, 'b': 20}
dict2 = {'a': 5, 'b': 10, 'c': 20}
df = pd.DataFrame([dict1, dict2])
print(df)
OR
(B)
read_csv() is used to load data from a CSV file into a Pandas DataFrame.
sep: Specifies the delimiter (e.g., comma, semicolon).
Data Handling Using Pandas – I· 3 Marks· Q30· 2027 Sample Paper Python
(A) (i) Write a Python program to create a Pandas Series named Inventory from the following dictionary:
stock = {'Pens': 150, 'Erasers': 80, 'Sharpeners': 60, 'Notebooks': 200}.
(ii) Consider two Series S1 and S2:
import pandas as pd
S1 = pd.Series([10, 20], index=['a', 'b'])
S2 = pd.Series([30, 40], index=['b', 'c'])
Write the output of the statement: print(S1 + S2)
OR
(B) Consider a DataFrame df as shown below:
Name IP Maths
0 Arpit 95 88
1 Vani 89 92
2 Chetan 78 80
Write Pandas statements to perform the following actions:
(i) Add a new column 'Total' containing the values [183, 181, 158].
(ii) Rename the 'Name' column to 'Student'.
(iii) Delete the 'Maths' column from the DataFrame.
Model answer
(A) (i)
import pandas as pd
stock = {'Pens': 150, 'Erasers': 80, 'Sharpeners': 60, 'Notebooks': 200}
Inventory = pd.Series(stock)
print(Inventory)
(ii) Output:
a NaN
b 50.0
c NaN
OR
(B)
(i) df['Total'] = [183, 181, 158]
(ii) df.rename(columns={'Name': 'Student'}, inplace=True)
(iii) df.drop(columns=['Maths'], inplace=True)
Data Handling Using Pandas – I· 5 Marks· Q36· 2027 Sample Paper Python
(i) Create a DataFrame named StoreDF as shown below using dictionary of series:
Items | Quantity | Unit_Price
0 Bread | 50 | 30
1 Milk | 100 | 25
2 Eggs | 120 | 6
Write suitable Pandas statements to Perform the following operations:
(ii) Add a new row containing data [Butter, 40, 55]
(iii) Display values of Items column only,