DataFrame Operations and CSV Files: Class 12 PYQs 2024–2026 with solutions
All 14 CBSE board questions asked from DataFrame Operations and CSV Files in 3 board papers, with the year, set and marks of each. 10 are solved free below. The Class 12 Informatics Practices PYQ Book: Solved Board Papers 2024-2026 (CBSE) has every solution, all chapters and 3 full board papers.
DataFrame Operations and CSV Files: board weightage
Board weightage 2024–2026
| Year | 2024 | 2025 | 2026 |
|---|---|---|---|
| Questions | 3 | 4 | 7 |
| Marks | 8 | 8 | 11 |
Most asked topics
14 questions from 3 papers. Repeated questions are shown once with every year they were asked.
Jump to: 1 mark2 marks3 marks4 marks5 marks
1 mark: MCQ and Assertion–Reason
Add a new row to DataFrame DF using: (A) DF.add() (B) DF.loc[] (C) DF.loc() (D) DF.addloc[]
Solution
(B) DF.loc[], e.g. DF.loc['new'] = [...].
What does print(df.loc['S2']) do?
Solution
(A) Displays the data of the row with label 'S2'.
CSV stands for ____ Separated Values: (A) Colon (B) CTRL (C) Comma (D) Caret
Solution
(C) Comma.
Value of axis to delete a column: (A) −1 (B) 0 (C) 1 (D) 2
Solution
(C) axis = 1.
Statement to change a column label in DataFrame df: (A) df = df.rename({old_name : new_name}, axis='columns') (B) df.rename(old_name, new_name), axis='columns' (C) df.change_name(…) (D) df.update({…}, axis='bar')
DataFrame.____[ ] is used for label indexing: (A) label (B) index (C) labindex (D) loc
A–R. (A): drop() can delete rows and columns. (R): The axis parameter specifies rows (axis=0) or columns (axis=1).
Which is NOT true about CSV files? (i) values separated by commas (ii) to_csv() saves a DataFrame to CSV (iii) a CSV file is created using a word processor (iv) CSV is a type of text file
2 marks: very short answer
(b) Explain Boolean Indexing with respect to DataFrames, with an example.
Solution
Boolean indexing filters rows of a DataFrame using a condition; only rows where the condition is True are returned. Example: for df with Name [Ajay, Riya, David, Peter] and Age [25, 30, 35, 40], df[df['Age'] > 30] returns the rows of David and Peter.
36 (II) Rename the row indexes of Scholarship to ['a','b','c','d','e']. (III) Remove the last row.
Solution
Scholarship.index = ['a', 'b', 'c', 'd', 'e'] # (II)Part (I) (creation with a dictionary of Series) is in Chapter 2.
# or Scholarship = Scholarship.rename(index={0:'a',1:'b',2:'c',3:'d',4:'e'})
Scholarship = Scholarship.drop(Scholarship.index[-1]) # (III)
# or Scholarship = Scholarship.iloc[:-1]
3 marks: short answer
(b) customer.csv (header Name, Age, City; rows Rudra 17 Kolkata, Divya 19 Dehradun, Nabeel 22 Lucknow): import into DataFrame DF and display the last two rows.
Solution
import pandas as pd
DF = pd.read_csv("customer.csv")
print(DF.tail(2))
Name Age City
1 Divya 19 Dehradun
2 Nabeel 22 Lucknow
DataFrame password (CodeName, Category, Frequency; rows 0–6: aaaaaa alpha 6.91, dragon animal 18.52, baseball sport 1.29, football sport 11.11, monkey animal 3.72, qwerty alpha 1.85, abcde alpha 3.19). (i) Add row abc123, alphanumeric, 12.8. (ii) Delete the row with label 2. (iii) Delete column Frequency.
Solution
password.loc[7] = ['abc123', 'alphanumeric', 12.8]
password.drop(2, inplace=True) # row label 2
password.drop('Frequency', axis=1, inplace=True)
CodeName Category
0 aaaaaa alpha
1 dragon animal
3 football sport
4 monkey animal
5 qwerty alpha
6 abcde alpha
7 abc123 alphanumeric
4 marks: SQL / case-based
DataFrame result (a–d above). (i) Output of print(result.loc[:,'Attempts'] > 1) (ii) Display the last three records. (iii) Display records with row labels 'a' and 'd'. OR read 'registration.csv' into DataFrame regis.
Solution
(i) a False, b True, c True, d False (Name: Attempts, dtype: bool). (ii) print(result.tail(3)) (or result.iloc[1:]). (iii) print(result.loc[['a','d']]). OR regis = pd.read_csv("registration.csv").
5 marks: programs and case studies
DataFrame Doctor (DID, NAME, DEPARTMENT, FEE; rows 0–4: 101 Dr. Joe ENT 1500, 102 Dr. Salma UROLOGY 1600, 103 Dr. Jeet ORTHO 1550, 104 Dr. Neha ENT 1200, 105 Dr. Vikram ORTHO 1700). (i) Print the last three rows. (ii) Display names of all doctors. (iii) Add column 'Discount' with 200 for all. (iv) Display rows with index 2 and 3. (v) Delete the column 'Department'.
Solution
print(Doctor.tail(3)) # (i)(Use the column labels exactly as in the DataFrame.)
print(Doctor['NAME']) # (ii)
Doctor['Discount'] = 200 # (iii)
print(Doctor.loc[[2, 3]]) # (iv) or Doctor[2:4]
Doctor.drop(['DEPARTMENT'], axis=1, inplace=True) # (v)
Get every solution for all chapters
- Every board question of every chapter, each fully solved the way the board gives marks
- 3 complete board papers, each followed by its solutions
- Weightage and most-asked topics for every chapter
- Instant PDF download, colour and black & white print copies
Revising the chapter first? Complete Informatics Practices Notes for Class 12 (CBSE 065, 2026-27) →
What you get in the pack
- CBSE Class 12 Informatics Practices board papers 2024 to 2026 (3 full board papers)
- All 9 chapters and 3 board papers complete
- Part A: all 9 chapters, questions sorted chapter-wise and by marks
- Year-wise weightage table and most-asked topics for every chapter
- Part B: each full board paper followed by its complete solutions
- Pandas, Matplotlib and SQL answers verified by running the code
- Only the current syllabus in Part A
All chapters in this pack
- PYQ Ch 1 Pandas Series
- PYQ Ch 2 DataFrame: Creation and Attributes
- PYQ Ch 3 DataFrame Operations and CSV Files
- PYQ Ch 4 Data Visualisation with Matplotlib
- PYQ Ch 5 SQL Revision and Single-row Functions
- PYQ Ch 6 SQL Aggregates, Grouping and Joins
- PYQ Ch 7 Computer Networks
- PYQ Ch 8 Introduction to the Internet and Web
- PYQ Ch 9 Societal Impacts
- Board Paper 2026 Set 90 with Solutions
- Board Paper 2025 Set 90 with Solutions
- Board Paper 2024 Set 90 with Solutions
