Free tutorials & notes in Hindi & English · Clean code examples 🧰 Free PDF & Image Tools →
🐼 Unit 1 – Pandas & Visualization (25 marks)  ·  Lesson 09

📝 Unit 1 Board Questions + Practice

What is on this page

Unit 1 of the 2026-27 syllabus carries 25 marks. Part A has 24 new practice questions with answers (click "Show answer" only after you try). Part B has all 50 questions of Unit 1 from the previous CBSE board papers (2023, 2024, 2025, 2026) in their original form – tables, code and internal choices included – each with a worked answer.

How to use for best result

1) Read the unit lessons first. 2) Solve Part A in your notebook, then check answers. 3) Attempt Part B paper-wise with a timer – about 1.5 minutes per mark. 4) Mark the questions you got wrong and revise that lesson again.

Part A – Practice questions with answers

U1-011 markImportant

A Series is created from a dictionary. Which becomes its index? (A) Dictionary keys (B) Dictionary values (C) Always 0,1,2... (D) Column names

Show answer

A: dictionary keys.

U1-021 markImportant

True or false: when Series use string labels, the slice s[1:3] includes positions 1, 2 and 3.

Show answer

False. Positions 1 and 2 only; the positional stop is excluded.

U1-031 markImportant

Which expression selects the row labelled R2? (A) df.loc["R2"] (B) df.loc("R2") (C) df.row["R2"] (D) df["R2"]

Show answer

A.

U1-041 markImportant

Fill in the blank: df.drop("Fee", axis=____) removes a column.

Show answer

1.

U1-051 markImportant

Choose the best chart for comparing student counts across four houses: line, bar or histogram.

Show answer

Bar chart.

U1-061 mark

Which plotting function saves the current figure to an image file?

Show answer

plt.savefig(), e.g. plt.savefig("chart.png") – call it before plt.show().

U1-072 marksImportant

Predict the labelled output; ignore the dtype line.

Python
import pandas as pd
s = pd.Series({'A':12, 'B':18, 'C':24, 'D':30})
print(s[1:3])
Show answer

B 18; C 24.

U1-082 marksImportant

Predict the result, including missing values.

Python
import pandas as pd
a = pd.Series([10,20,30], index=['x','y','z'])
b = pd.Series([2,4,6], index=['y','z','w'])
print(a + b)
Show answer

Label-aligned values: w NaN, x NaN, y 22.0, z 34.0 (order may be shown sorted).

U1-092 marksImportant

Correct all errors in this code.

Python
import Pandas as pd
s = pd.series([40,50,60], Index=['P','Q','R'])
Print(s)
Show answer
Python
import pandas as pd
s = pd.Series([40, 50, 60], index=['P', 'Q', 'R'])
print(s)

Errors: Pandas → pandas, series → Series, Index → index, Print → print.

U1-102 marksImportant

Create a Series with scalar value 100 and labels Jan, Feb and Mar.

Show answer
Python
pd.Series(100, index=['Jan','Feb','Mar'])
U1-112 marksImportant

Given s = pd.Series([11,22,33,44,55], index=list("abcde")), write statements to display its first two and last three elements.

Show answer
Python
print(s.head(2))
print(s.tail(3))
U1-122 marks

Write one difference each between a Series and a DataFrame regarding dimensions and labelled axes.

Show answer

Series: one-dimensional with an index. DataFrame: two-dimensional with row index and column labels.

U1-133 marksImportant

Create a Series from a NumPy array containing 72, 84 and 96 with labels English, IP and Maths. Display the Series after adding 4 to every value.

Show answer
Python
import numpy as np
import pandas as pd
s=pd.Series(np.array([72,84,96]),index=['English','IP','Maths'])
print(s+4)
U1-143 marksImportant

Using a dictionary of Series, create df with row labels S1, S2, S3: Name = Asha, Bharat, Charu; Marks = 81, 67, 92. Display it.

Show answer
Python
df=pd.DataFrame({'Name':pd.Series(['Asha','Bharat','Charu'],index=['S1','S2','S3']),'Marks':pd.Series([81,67,92],index=['S1','S2','S3'])})
print(df)
U1-153 marksImportant

Create a DataFrame from a list of two dictionaries: {Book: Python, Price: 450} and {Book: SQL, Price: 380}. Use row labels B1 and B2.

Show answer
Python
pd.DataFrame([{'Book':'Python','Price':450},{'Book':'SQL','Price':380}],index=['B1','B2'])
U1-163 marksImportant

For df from U1-14, independently write statements to: (i) select rows S1 and S3, (ii) display Name and Marks where Marks >= 80, (iii) rename Marks to Score.

Show answer
Python
df.loc[['S1','S3']]
df.loc[df['Marks']>=80,['Name','Marks']]
df.rename(columns={'Marks':'Score'},inplace=True)
U1-173 marksImportant

The file attendance.csv has a header and columns Name, Days. Read it into att, print its last two records, and export it to checked.csv without the DataFrame index.

Show answer
Python
att=pd.read_csv('attendance.csv')
print(att.tail(2))
att.to_csv('checked.csv',index=False)
U1-183 marks

Using DataFrame df from U1-14, write a loop that prints each row label and the corresponding Name using iterrows().

Show answer
Python
for label,row in df.iterrows(): print(label,row['Name'])
U1-194 marksImportant

For df from U1-14, execute these in order: (i) add column Bonus with value 5, (ii) add S4 with Name Deepa, Marks 76, Bonus 5, (iii) remove row S2, (iv) remove Bonus.

Show answer
Python
df['Bonus']=5
df.loc['S4']=['Deepa',76,5]
df.drop('S2',inplace=True)
df.drop(columns=['Bonus'],inplace=True)
U1-204 marksImportant

Complete the four blanks to display a labelled histogram.

Python
import matplotlib.pyplot as plt
marks = [42,48,53,61,67,72,78,83,89,95]
plt.____(marks, bins=[40,60,80,100], label='Students')
plt.____('Marks')
plt.ylabel('Frequency')
plt.title('Marks distribution')
plt.____()
plt.____()
Show answer

hist; xlabel; legend; show.

U1-215 marksImportant

Write a program to plot a line chart for months Apr, May, Jun, Jul and book issues 120, 150, 135, 180. Add axis labels, title Library Issues and legend Issues. Save as issues.png and display.

Show answer
Python
import matplotlib.pyplot as plt
plt.plot(['Apr', 'May', 'Jun', 'Jul'], [120, 150, 135, 180], label='Issues')
plt.xlabel('Month')
plt.ylabel('Books issued')
plt.title('Library Issues')
plt.legend()
plt.savefig('issues.png')
plt.show()
U1-225 marksImportant

Write a program for a bar chart: houses Red, Blue, Green, Yellow; points 240, 280, 260, 300. Include a title, both axis labels and save as houses.png.

Show answer
Python
import matplotlib.pyplot as plt
plt.bar(['Red', 'Blue', 'Green', 'Yellow'], [240, 280, 260, 300])
plt.title('House points')
plt.xlabel('House')
plt.ylabel('Points')
plt.savefig('houses.png')
plt.show()
U1-235 marksImportant

Create scholarship using a dictionary of Series: Name = Isha, Kabir, Meera, Nitin; Amount = 5000, 6500, 7200, 4800. Set row labels to a,b,c,d; display names with Amount >= 6000; remove row d.

Show answer
Python
scholarship=pd.DataFrame({'Name':pd.Series(['Isha','Kabir','Meera','Nitin']),'Amount':pd.Series([5000,6500,7200,4800])})
scholarship.index=['a','b','c','d']
print(scholarship.loc[scholarship['Amount']>=6000,'Name'])
scholarship.drop('d',inplace=True)
U1-243 marks

Assertion: a DataFrame may have a text column and a numeric column. Reason: every DataFrame column must contain only numeric values. Choose the correct assertion-reason option, explain it, and give a two-column example.

Show answer

C: assertion true, reason false. Example pd.DataFrame({'Name':['Asha'],'Marks':[81]}).

Part B – Previous year board questions (Unit 1)

CBSE Board Paper 2026 – 14 questions

Board 2026 · Q1
CBSE 2026 Class 12 IP board question Q1, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

False – the positional index is always an integer (0, 1, 2 …); only the label index can be a string.

Board 2026 · Q2
CBSE 2026 Class 12 IP board question Q2, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(B) DF.loc[]

Board 2026 · Q4
CBSE 2026 Class 12 IP board question Q4, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(B) To compare the number of students in different classes.

Board 2026 · Q8
CBSE 2026 Class 12 IP board question Q8, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(A) Display the data of the row having label 'S2'.

Board 2026 · Q12
CBSE 2026 Class 12 IP board question Q12, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(C) Comma

Board 2026 · Q14
CBSE 2026 Class 12 IP board question Q14, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(C) The keys of the dictionary become the indices of the Series.

Board 2026 · Q15
CBSE 2026 Class 12 IP board question Q15, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(B) The element at the end index is excluded from the output.

Board 2026 · Q18
CBSE 2026 Class 12 IP board question Q18, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(C) axis = 1

Board 2026 · Q20
CBSE 2026 Class 12 IP board question Q20, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(C) – Assertion is true, Reason is false: each DataFrame column can have its own data type (numbers, text, dates).

Board 2026 · Q22
CBSE 2026 Class 12 IP board question Q22, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(a) Any two: pandas provides fast, easy data structures (Series and DataFrame) with labelled indexes; it can read and write CSV, Excel and SQL data; it handles missing data; it supports grouping, sorting, filtering and statistics on large data.

OR (b) Boolean indexing selects only those rows for which a condition is True. A condition on a column gives a Series of True/False values, which is used inside [ ] or loc.

Python
df = pd.DataFrame({'Name': ['Asha', 'Ravi', 'Neha'], 'Marks': [78, 45, 91]})
print(df[df['Marks'] > 60])      # rows of Asha and Neha only
Board 2026 · Q28
CBSE 2026 Class 12 IP board question Q28, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(a) Blanks: numpy · array · Series · index

Python
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) As printed, the code uses S2 (capital S) which is not defined, so Python gives NameError. If S2 is corrected to s2, the output is:

Output
a    NaN
b    6.0
c    8.0
d    NaN
dtype: float64
Board 2026 · Q30
CBSE 2026 Class 12 IP board question Q30, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(a)

Python
import pandas as pd
days = pd.Series([31, 31, 30, 31], index=['July', 'Aug', 'Sept', 'Oct'])
print(days)

OR (b)

Python
import pandas as pd
DF = pd.read_csv('customer.csv')
print(DF.tail(2))
Board 2026 · Q33
CBSE 2026 Class 12 IP board question Q33, Unit 1 Data Handling using Pandas and Data Visualization (part 1)CBSE 2026 Class 12 IP board question Q33, Unit 1 Data Handling using Pandas and Data Visualization (part 2)
Show answer

I. plt.hist(Ages, bins=binsize, edgecolor='black', label='Participants') II. plt.xlabel('Age') III. plt.legend() IV. plt.show()

Board 2026 · Q36
CBSE 2026 Class 12 IP board question Q36, Unit 1 Data Handling using Pandas and Data Visualization
Show answer
Python
import pandas as pd
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])
Scholarship = pd.DataFrame({'Name': Name, 'Course': Course, 'Amount': Amount})   # I
print(Scholarship)
Scholarship.index = ['a', 'b', 'c', 'd', 'e']                                     # II
Scholarship = Scholarship.drop('e')                                               # III (last row)

CBSE Board Paper 2025 – 14 questions

Board 2025 · Q1
CBSE 2025 Class 12 IP board question Q1, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

False – pd.DataFrame() creates an empty DataFrame.

Board 2025 · Q6
CBSE 2025 Class 12 IP board question Q6, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(C) Numeric – 0, 1, 2, … (RangeIndex).

Board 2025 · Q7
CBSE 2025 Class 12 IP board question Q7, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(D) savefig()

Board 2025 · Q9
CBSE 2025 Class 12 IP board question Q9, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(C) Series

Board 2025 · Q13
CBSE 2025 Class 12 IP board question Q13, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(C) ser[points] (written as ser['points'] when the label is a string).

Board 2025 · Q15
CBSE 2025 Class 12 IP board question Q15, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(B) numpy

Board 2025 · Q17
CBSE 2025 Class 12 IP board question Q17, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(A) df = df.rename({old_name : new_name}, axis='columns')

Board 2025 · Q18
CBSE 2025 Class 12 IP board question Q18, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(D) loc

Board 2025 · Q20
CBSE 2025 Class 12 IP board question Q20, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(A) – both are true and the axis parameter (0 = rows, 1 = columns) explains how drop() deletes rows or columns.

Board 2025 · Q22
CBSE 2025 Class 12 IP board question Q22, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(a) Series is one-dimensional with only a row index; a DataFrame is two-dimensional with a row index and column labels. A Series holds one column of data (one data type), while each column of a DataFrame can have a different data type.

OR (b) Slicing uses [start:stop]; with positions the stop is excluded, with labels the stop is included.

Python
s = pd.Series([10, 20, 30, 40], index=['a', 'b', 'c', 'd'])
print(s[1:3])        # b 20, c 30  (positions 1 and 2)
print(s['b':'d'])    # b 20, c 30, d 40  (end label included)
Board 2025 · Q28
CBSE 2025 Class 12 IP board question Q28, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(a) Corrections: import pandas as pd, Series, index, print.

Python
import pandas as pd
data = [50, 15, 40]
series = pd.Series(data, index=['x', 'y', 'z'])
print(series)

OR (b) Blanks: pandas · 'COLOUR':'Green' · data · df

Python
import pandas as pd
data = [{'COLOUR': 'Red', 'NAME': 'Apple', 'QTY': 10},
        {'COLOUR': 'Blue', 'NAME': 'Berry', 'QTY': 15},
        {'COLOUR': 'Green', 'NAME': 'Guava', 'QTY': 20}]
df = pd.DataFrame(data)
print(df)
Board 2025 · Q30
CBSE 2025 Class 12 IP board question Q30, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(a)

Python
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)

OR (b)

Python
import pandas as pd
import numpy as np
arr = np.array([10, 20, 30, 40, 50])
s = pd.Series(arr, index=['A', 'B', 'C', 'D', 'E'])
print(s)
Board 2025 · Q33
CBSE 2025 Class 12 IP board question Q33, Unit 1 Data Handling using Pandas and Data Visualization (part 1)CBSE 2025 Class 12 IP board question Q33, Unit 1 Data Handling using Pandas and Data Visualization (part 2)
Show answer

(i) import matplotlib.pyplot as plt (ii) plt.plot(days, temp) (iii) plt.xlabel('Days') (iv) plt.title('Temperature Over 5 Days')

Board 2025 · Q36
CBSE 2025 Class 12 IP board question Q36, Unit 1 Data Handling using Pandas and Data Visualization
Show answer
Python
print(Doctor.tail(3))                          # (i)
print(Doctor['Name'])                          # (ii)
Doctor['Discount'] = 200                       # (iii)
print(Doctor.loc[2:3])                         # (iv)
Doctor = Doctor.drop('Department', axis=1)     # (v)

CBSE Board Paper 2024 – 11 questions

Board 2024 · Q7
CBSE 2024 Class 12 IP board question Q7, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(iii) – a CSV file is a plain text file; it is not created with a word processor.

Board 2024 · Q10
CBSE 2024 Class 12 IP board question Q10, Unit 1 Data Handling using Pandas and Data Visualization (part 1)CBSE 2024 Class 12 IP board question Q10, Unit 1 Data Handling using Pandas and Data Visualization (part 2)
Show answer

(iv) – the new label 'Four' is added at the end of the Series.

Board 2024 · Q12
CBSE 2024 Class 12 IP board question Q12, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(iv) S1.head[0:5] – head is a method and must be called with ( ), not sliced with [ ].

Board 2024 · Q18
CBSE 2024 Class 12 IP board question Q18, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(ii) – both statements are true, but default numeric indexes do not explain why a Series is 1-D and a DataFrame is 2-D.

Board 2024 · Q20
CBSE 2024 Class 12 IP board question Q20, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

Corrections: Pandas → pandas, [ ] → { } (dictionary), stud used in Series, p → pd.

Python
import pandas as pd
stud = {'Name': 'Ramya', 'Class': 11, 'House': 'Red'}
s = pd.Series(stud)
print(s)
Board 2024 · Q22
CBSE 2024 Class 12 IP board question Q22, Unit 1 Data Handling using Pandas and Data Visualization
Show answer
Output
printer    12
webcam     15
dtype: int64
Board 2024 · Q24
CBSE 2024 Class 12 IP board question Q24, Unit 1 Data Handling using Pandas and Data Visualization
Show answer
Python
S2 = pd.Series(['IP', 'HSc', 'IP'], index=[10, 16, 18])
S3 = pd.Series([56, 67, 86], index=[10, 16, 18])
xiia = {'Name': S1, 'Subject': S2, 'Marks': S3}
df = pd.DataFrame(xiia)
Board 2024 · Q27
CBSE 2024 Class 12 IP board question Q27, Unit 1 Data Handling using Pandas and Data Visualization
Show answer
Python
import pandas as pd
voters = [{'Voter_Name': 'Arjun', 'Voter_Age': 35},
          {'Voter_Name': 'Bala', 'Voter_Age': 23},
          {'Voter_Name': 'Govind', 'Voter_Age': 25},
          {'Voter_Name': 'Dhruv', 'Voter_Age': 19},
          {'Voter_Name': 'Navya', 'Voter_Age': 18}]
df = pd.DataFrame(voters, index=['Ar1001', 'Ba3002', 'Go4002', 'Dh4007', 'Na6005'])
print(df)
Board 2024 · Q30
CBSE 2024 Class 12 IP board question Q30, Unit 1 Data Handling using Pandas and Data Visualization
Show answer
Python
password.loc[7] = ['abc123', 'alphanumeric', 12.8]     # (i)
password = password.drop(2)                            # (ii)
password = password.drop('Frequency', axis=1)          # (iii)
Board 2024 · Q32
CBSE 2024 Class 12 IP board question Q32, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(i)

Output
a    False
b     True
c     True
d    False
Name: Attempts, dtype: bool

(ii) and (iii):

Python
print(result.tail(3))              # (ii)
print(result.loc[['a', 'd']])      # (iii)
regis = pd.read_csv('registration.csv')     # OR (iii)
Board 2024 · Q35
CBSE 2024 Class 12 IP board question Q35, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(a) Bar chart:

Python
import matplotlib.pyplot as plt
Fruits = ['Apple', 'Guava', 'Papaya', 'Grapes', 'Mango']
Price = [150, 70, 50, 30, 120]
plt.bar(Fruits, Price)
plt.title('Price of Fruits')
plt.xlabel('Fruits')
plt.ylabel('Price (Rs)')
plt.savefig('fruits.png')
plt.show()

OR (b) Line chart:

Python
import matplotlib.pyplot as plt
month = ['April', 'May', 'June', 'July', 'August']
co2 = [40, 50, 30, 60, 20]
plt.plot(month, co2)
plt.title('Month wise CO2 emission')
plt.xlabel('Month')
plt.ylabel('Percentage')
plt.savefig('emission.png')
plt.show()

CBSE Board Paper 2023 – 11 questions

Board 2023 · Q10
CBSE 2023 Class 12 IP board question Q10, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(iii) – default index 0, 1, 2 with value 0 in each row (plus dtype: int64).

Board 2023 · Q11
CBSE 2023 Class 12 IP board question Q11, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(ii) Dataframe

Board 2023 · Q12
CBSE 2023 Class 12 IP board question Q12, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(iii) bar – a bar chart compares values of different salesmen (categories).

Board 2023 · Q18
CBSE 2023 Class 12 IP board question Q18, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

(iii) / C – Assertion is true, Reason is false. With the + operator a missing label gives NaN; missing values are filled with 0 only when we use add() with fill_value=0.

Board 2023 · Q22
CBSE 2023 Class 12 IP board question Q22, Unit 1 Data Handling using Pandas and Data Visualization
Show answer
Python
import pandas as pd
country = pd.Series(['New Delhi', 'London', 'Copenhagen', 'Bangkok'],
                    index=['India', 'UK', 'Denmark', 'Thailand'])
print(country)
Board 2023 · Q24
CBSE 2023 Class 12 IP board question Q24, Unit 1 Data Handling using Pandas and Data Visualization
Show answer

2*(3,10) repeats the tuple, so data = (3, 10, 3, 10).

Output
0     3
1    10
2     3
3    10
dtype: int64
Board 2023 · Q25
CBSE 2023 Class 12 IP board question Q25, Unit 1 Data Handling using Pandas and Data Visualization (part 1)CBSE 2023 Class 12 IP board question Q25, Unit 1 Data Handling using Pandas and Data Visualization (part 2)
Show answer
Python
player.index = ['Player1', 'Player2', 'Player3', 'Player4', 'Player5']   # (i)
player.rename(columns={'points': 'netpoint'}, inplace=True)               # (ii)
Board 2023 · Q27
CBSE 2023 Class 12 IP board question Q27, Unit 1 Data Handling using Pandas and Data Visualization
Show answer
Python
import pandas as pd
names = ['Hydrogen', 'Helium', 'Lithium', 'Beryllium']
symbol = pd.Series(['H', 'He', 'Li', 'Be'], index=names)
atomic = pd.Series([1, 2, 3, 4], index=names)
elements = pd.DataFrame({'Symbol': symbol, 'Atomic Number': atomic})
print(elements)
Board 2023 · Q28
CBSE 2023 Class 12 IP board question Q28, Unit 1 Data Handling using Pandas and Data Visualization
Show answer
Python
health = health.drop(3)                       # (i) row of Tuberculosis (index 3)
health.loc[4] = ['Malaria', 'Protozoa']       # (ii)
print(health.tail(2))                         # (iii)
Board 2023 · Q33
CBSE 2023 Class 12 IP board question Q33, Unit 1 Data Handling using Pandas and Data Visualization (part 1)CBSE 2023 Class 12 IP board question Q33, Unit 1 Data Handling using Pandas and Data Visualization (part 2)
Show answer

Line graph:

Python
import matplotlib.pyplot as plt
smarks = [10, 40, 30, 60, 55]
sname = ["Sahil", "Deepak", "Anil", "Ravi", "Riti"]
plt.plot(sname, smarks)
plt.title("Marks secured by students in Term-1")
plt.xlabel("Student Name")
plt.ylabel("Marks Scored")
plt.show()

OR – bar graph:

Python
import matplotlib.pyplot as plt
sales = [450, 300, 500, 650]
qtr = ["QTR1", "QTR2", "QTR3", "QTR4"]
plt.bar(qtr, sales)
plt.title("Sales each quarter")
plt.xlabel("Quarter")
plt.ylabel("Sales")
plt.show()
Board 2023 · Q35
CBSE 2023 Class 12 IP board question Q35, Unit 1 Data Handling using Pandas and Data Visualization
Show answer
Python
print(mdf.loc[1:2])                     # (A)(i) roll numbers 2 and 3 (row labels 1 and 2)
mdf['Maths'] = mdf['Maths'] + 4         # (A)(ii)
print(mdf[mdf['Maths'] < 10][['Rollno', 'Name']])   # (B)

OR (B):

Python
print(mdf['English'] + mdf['Hindi'] + mdf['Maths'])
Next

Next: Unit 2 – start with SQL Math Functions.

← Class 12 Informatics Practices
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

Next topicSQL Math Functions: POWER, ROUND, MOD Your progress: 9 / 29 (31%) · Lesson 10 / 29 Continue →

How was this lesson?

Your feedback helps us make the content better.

Write a review or suggestion (optional)

After approval, your name and city may appear publicly with your review. Please do not write your email or phone number.

▶ CodingEasily on YouTube

Learn with video lessons in easy Hindi

Featured video: RDBMS Part 3 – Class XI Commerce IT

▶ Subscribe – it’s free