On this page
Pandas questions in Class 12 Informatics Practices look easy until you have to predict the exact output of a slice or explain where a NaN came from. This post covers the Series and DataFrame skills the syllabus lists. Every snippet below was run in pandas, and you get the real output, the mistakes that cost marks, and a practice routine.
What does the 2026-27 syllabus ask for?
The CBSE Informatics Practices curriculum for 2026-27 gives Unit 1, "Data Handling using Pandas and Data Visualization", 25 of the 70 theory marks. For Series, it lists creation from an ndarray, a dictionary or a scalar value, mathematical operations, head() and tail(), and selection, indexing and slicing. For DataFrames, it lists creation from a dictionary of Series, a list of dictionaries or a CSV file, iteration, adding, selecting, deleting and renaming rows and columns, indexing by labels, Boolean indexing, and import and export between CSV files and DataFrames. The matching NCERT chapter is Data Handling Using Pandas - I.
How do you build a DataFrame from a dictionary of Series?
Here is a small marks table.
import pandas as pd
marks = {'Physics': pd.Series([78, 64, 91], index=['Asha', 'Ravi', 'Meena']),
'Maths': pd.Series([85, 59, 88], index=['Asha', 'Ravi', 'Meena'])}
df = pd.DataFrame(marks)
df['Total'] = df['Physics'] + df['Maths']
print(df)Output:
Physics Maths Total
Asha 78 85 163
Ravi 64 59 123
Meena 91 88 179The dictionary keys become column labels, and the Series index becomes the row labels. Adding a column is a single assignment, and the addition works row by row: 78 + 85 = 163, 64 + 59 = 123 and 91 + 88 = 179. The shape is now (3, 3).
What is the difference between loc and iloc?
The pandas indexing guide states that .loc is label based and .iloc is integer-position based. It also warns that, contrary to usual Python slices, a label slice includes both the start and the stop.
print(df.loc['Asha':'Ravi', 'Physics']) # labels: stop included
print(df.iloc[0:1, 0]) # positions: stop excludedOutput:
Asha 78
Ravi 64
Name: Physics, dtype: int64
Asha 78
Name: Physics, dtype: int64The label slice returned two rows. The position slice 0:1 returned one. This is the single most common output question.
How does Boolean indexing work?
Put a condition inside square brackets to keep only the rows where it is True. With two conditions, use & or | and put brackets around each condition.
print(df[df['Maths'] > 80])
print(df[(df['Physics'] > 70) & (df['Maths'] > 86)])The first gives Asha and Meena, since Ravi's 59 fails. The second gives only Meena, because Asha's Maths mark of 85 is not above 86. If you drop the inner brackets, Python applies & before >, and the code raises an error.
Why does adding two Series give NaN?
Series arithmetic matches values by index label, not by position.
s1 = pd.Series([10, 20, 30], index=['a', 'b', 'c'])
s2 = pd.Series([1, 2, 3], index=['b', 'c', 'd'])
print(s1 + s2)
print(s1.add(s2, fill_value=0))The first gives a NaN, b 21.0, c 32.0, d NaN. Labels a and d exist in only one Series, so there is nothing to add them to. The second uses fill_value=0 and gives a 10.0, b 21.0, c 32.0, d 3.0. The values print as floats because NaN is a float, so pandas converts the whole result. NCERT works through the same idea with its own examples.
How do you delete, rename and save?
df.drop('Total', axis=1) removes a column. axis=0 (the default) removes a row by label.
df.rename(columns={'Maths': 'Mathematics'}) renames a column and returns a new DataFrame. Assign it back, or the change is lost.
df.to_csv('marks.csv') writes the index as the first, unnamed column. Read it back with pd.read_csv('marks.csv', index_col=0) to get the names as row labels again.
Which slips cost the most marks?
Treating a loc label slice as stop-exclusive.
Forgetting that misaligned indexes give NaN, and that the result becomes float.
Mixing up axis=0 (rows) and axis=1 (columns) in drop().
Writing df['Physics', 'Maths'] instead of df[['Physics', 'Maths']] to select two columns.
Expecting rename() or drop() to change df without assigning the result back.
A practice routine for the pandas unit
Daily, 20 minutes: write five output-prediction questions on a small DataFrame of your own, such as cricket scores or monthly rainfall. Predict, run and compare.
Twice a week: rebuild one DataFrame three ways: from a dictionary of Series, from a list of dictionaries and from a CSV file.
Weekly: take one past CBSE question and write the full code with comments, then explain it aloud as you would in the viva.
Before the practical: keep a one-page list of the methods in the syllabus, with one example each.
If you want help planning which of these to work on first, Fermi's AI tutor can work out what you already know and build a plan for the session. For the arrays that come before pandas, see our post on NumPy arrays in Class 11 IP, and for the next unit, SQL functions in Class 12 IP.
Tonight, build the marks DataFrame above, then predict and check the output of three different loc and iloc slices.



