Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

LEADERS PRIVATE SCHOOL, SHARJAH

WORK SHEET – II 2024-25


INFORMATICS PRACTICES

GRADE: XII TOPIC: Data Handling Using Pandas I

Instructions:
Write all the answers in the notebook. Submit to your respective teacher within a
week

1) The following statement will _________


df = df.drop(['Name', 'Class', 'Rollno'], axis = 1)
#df is a DataFrame object

a. delete three columns having labels ‘Name’, ‘Class’ and ‘Rollno’


b. delete three rows having labels ‘Name’, ‘Class’ and ‘Rollno’
c. delete any three columns
d. return error
2) Consider the following DataFrame ‘STUD’

Write statements to perform the following operations on the dataframe:


1) Add a row [7, Preeti Arora,25,23,22,24]

2) Ms. Sharma, the class teacher wants to add a new column, ‘Grade’ with the
values ‘A’, ‘B’, ‘A’, ‘A’, ‘B’, ‘A’
3) Display column labels
4) Remove the details of Tanish Goel
5) Add a column ‘Total’ that will display the sum of UT1, UT2, UT3 & UT4
6) Remove the column Grade from the datafarame.

3) Write the output of the following code:

4) A dictionary Grade contains the following:


Grade={‘Name’:[ ‘Rashmi’,’Harsh’,’Ganesh’, ‘Priya’,’Vivek’],
‘Grade’:[‘A1’,’A2’,’B1’,’A1’,’B2’]}
Write statements for the following:
(i) Create a Dataframe named “Gr”.
(ii) Add a column called ‘marks’ with following data:
[97,92,95,89,96,82]
(iii) Write a command to display records in ascending order of marks.
(iv) Delete 3rd and 5th rows

5) Write a program in Python Pandas to create the following DataFrame Batsman


from a Dictionary:

Write python statements to perform the following operations on the DataFrame :


1)Add both the scores of a batsman and assign to column “Total”
2)Display the Lowest score in both Score1 and Score2 of the DataFrame.
3)Display the DataFrame

6)

7) Write a python program to create a dataframe with headings CS and IP from the
list [[79,92],[86,96],[85,91],[80,99]]

8) Write the output of the following:


import pandas as pd
df=pd.DataFrame([45,50,41,56],index=[True, False, True, False])
print(df.loc[True])
9)

10) Consider the dataframe : SMARKS

M1 M2 M3 M4

Kabir 34 50 78 45

Seema 45 56 32 66

David 35 56 77 89

Ramya 99 56 45 34

Write python statements to perform the following operations:

a) To rename the columns with Physics,Math,Bio,IP

b) To rename David and Ramya with Sachin and Ranbeer

c) To display Sachin’s marks in Bio and IP

d) To display the Physics and IP marks for Seema and Kabir

You might also like