Professional Documents
Culture Documents
12 Ip 01 03 24
12 Ip 01 03 24
DPT 1
INFORMATICS PRACTICES
( Pure science)
01.04.2024
Total Marks : 25 Duration : 40 minutes
2 Write a code to store data of 4 students details in a dataframe with following columns: name, age, current course, 2
university.
3 Aman store some data in the form of nested list. Later on he created dataframe "DF" from the list given below by 2
writing the following code. How many columns will be there in "DF".
L1 = [["Aman", "Cricket", "7th"], ["Ankit", "Hockey", "11th"], ["Sunita", "Basket ball", "9th"]]
import pandas as pd
L1 = [["Aman", "Cricket", "7th"], ["Ankit", "Hockey", "11th"], ["Sunita", "Basket ball", "9th"]]
DF = pd.DataFrame(L1)
print(DF)
4 Consider the following dataframe 'tempurature: 3
City max
0 Ahmedabad 31
2 Surat 29
3 Vadodara 32
Write suitable python code to:
a) Add new column min with these data: [25,22,19,28]
b) Write code to display no of rows
c) Write code to display no of columns
5 Fill in the blanks to produce the Output 3
import pandas as pd
L1 = ["Anil", "Ruby", "Raman", "Suman"]
L2 = [35, 56, 48, 85]
DF = pd.DataFrame([L1, L2], ___________________
print(DF)
OUTPUT
Ist IInd IIIrd IVth
A Anil Ruby Raman Suman
B 35 56 48 85
6 Observe the following code and write statements for the below give 4
import pandas as pd X
player1={'IG1':34, 'IG2': 0, 'IG3':23}
player2={'IG1':21, 'IG2':10, IG3':39}
pl={'p1':player1,'p2':player2}
df=pd.DataFrame(pl)
a) Display data of player scored more than 30 runs
b) Display all rows of first inning of all players
7 Write python code to create a dataframe by using following data: 4
[[201,'Manoj',4500], [202, 'Dhara', 3200], [203,'Mohini', 2300]]
i. Dataframe name should be cust
ii. Use column headings as: cust_id,cust_name and amount tutor