0% found this document useful (0 votes)
34 views5 pages

LL

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views5 pages

LL

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CLASS-XII IP WORKSHEET – 3, DATAFRAMES

1. Write python statements to create a data frame for the following data.
Name Age Designation
Heema 30 Teacher
Sami 40 Principal
Rajni 28 Clerk

2. Write the output of the following code:


import pandas as pd
import numpy as np
d = {'Product':['Pen','Pencil','Eraser','Marker'],\
'Quantity':[10,15,20,25],\
'Price':[100,150,120,90]}
df1 = pd.DataFrame(d)
print(“The dataframe is:\n”,df1)
print(df1.shape)
print(df1.empty)
print(df1.size)
print(df1.T)
print(df1.values)
print('Empty:',df1.empty)
3. Write the output of the following:
import pandas as pd
import numpy as np
d = {'Rollno':[10,11,12,13],\
'IP':[90,92,95,93],\
'CS':[80,90,85,95]}
df = pd.DataFrame(d)
print(df.index)
print(df.axes)
print(df.columns)
print(df.dtypes)
4. Write a program to create a dataframe storing salesmen details (name,zone,sales) of five
salesman.
5. Write the python code to generate the following output:-

6. What will be the output :


dict=[{‘year’:2018,’population’:1250},{‘year’:2019,’population’:2025},{‘year’:2020}]
df = pd.Dataframe(dict)
print(df)
7. Find out the error from the following :
dict = [{‘eco:60,’acc’:75},{‘eng’:30, ‘bst’:78},{‘acc’:90,’eco’:78}]
df2=pd.dataframe dict, column=(’eco’, ‘acc’)
8. Create a dataframe from two series objects where one series store temperature and second
series store humidity and indexes should be week days name.
9. Write python program to create an empty dataframe.
WORKSHEET 4 PANDAS : DATA FRAME
1. Create the following Data Frame SBSB_XI
Name DOB GENDER MOBILE Height Weight
0 ADITYA PAL 01/12/2002 M 9876543210 5.8 55
1 PALAK 08/11/2002 F 9987654321 5.0 45
AGRAWAL
2 KULDEEP 12/02/2003 M 9998765432 5.3 48
SINGH
3 NEHA 02/05/2003 F 9999765432 5.3 50
4 PRAVESH 03/05/2002 M 8885963212 5.5 54
5 SUMIT 05/03/2001 M 8956664232 5.6 56
PACHORI
6 TANUSHKA 02/02/2002 F 9856472362 5.1 50

2. Write the result of following Statements


a. print(df.index)
b. print(df.columns)
c. print(df.ndim)

3. What the following statement is doing?


a. df['city']=['Gwalior','Indore','Agra','Dewas',’Gwalior’,’Indore’]
b. df.Name[7]=['NANDITA ',’01/01/2002’,’F’,99988877766,5.3,51] c. df.loc[2, : ]
d. df.loc[3:5, : ]
e. df.loc[2:4, ‘Name’ : ’Gender’]

4. Add One more Column ‘FName’ with suitable contents to the above Data Frame

5. Identify the Output of the following commands

print('Transpose ')

print(df.T)
WORKSHEET 5 PANDAS : DATA FRAME
1. Create the following Data Frame ‘Employee’
Name Age Department Sal Gender
1 SAGAR 62 COMPUTER 10000 M
2 PABITRA 22 HISTORY 15000 M
3 PRAKASH 32 GEOGRAPHY 12000 M
4 AKASH 12 COMPUTER 15000 M
5 NABANITA 30 HISTORY 12000 F
6 KANIKA 16 PHYSICS 20000 F
7 MAYURIKA 29 CHEMISTRY 18000 F
8 PRADEEP 45 ACCOUNTANCY 14000 M
9 SANJOY 19 H.SCIENCE 12000 M
10 ANKUR 23 C.ART 15000 M

2. What the following statements are doing?


a. Employee.info()
b. Employee.head(3)
c. Employee.tail(4)
d. Employee.head()
e. Employee[‘DOJ’]=NaN
3. What is the difference between following two commands
a. Employee.drop(range(0,2))
b. del Employee ['Age']

4. Identify the Output of the following commands

print('size ',Employee.size)

print('Dimensions ',Employee.ndim)

print('Values ',Employee.values)

print('shape',Employee.shape)

print('Empty ',Employee.empty)

You might also like