DF1
DF1
import pandas as pd
d={‘Mouse’:[150,200,300,400],‘Keyboard’:[180,200,190,300], ‘Scanner
’:[200,280,330,450]}
df=pd.DataFrame(d,index=[‘Jan’,’Feb’,’March’,’April’])
2) Write a python code to create a data frame with appropriate headings from
the list given below:
['S101', 'Amy', 70], ['S102', 'Bandhi', 69], ['S104', 'Cathy', 75], ['S105', 'Gundaho', 82]
import pandas as pd
d = {2014:[100.5,150.8,200.9,30000,4000],
2015:[12000,18000,22000,30000,45000],
2016:[20000,50000,70000,10000,125000],
2017:[50000,60000,70000,80000,90000]}
Sales=pd.DataFrame(d,index=['Madhu',"Kusum","Kinshuk","Ankit","Shruti"])
print(Sales)
import pandas as pd
d={‘Name’:[‘Ann’, ‘Manav’,’Sanjay’, ‘Balu’,’Shiv’],
‘PT1’:[35,42,43,44,39],’Weekly_Test’:[24,16,19,22,23]}
Df=pd.DataFrame(_______________) # Statement1
print(_____________________) #Statement2
print(df[::-2]) #Statement3
df=df.___________ #Statement4
df____________ #Statement5
ii. Print the name and PT1 marks who got more than 23 –Statement 2
5) Create a DataFrame using a dictionary that stores Age, Location and Name
of candidates applied for an International Sports Event. Screen shot as
follows:
7) Mr. Tarun, a data analyst has designed the DataFrame DF1 that contains
data about Cyber Security Olympiad with ‘CS1’, ‘CS2’, ‘CS3’, ‘CS4’,
‘CS5’ as indexes shown below. Answer the following questions:
10) Write a Python code to create a DataFrame with appropriate column headings
from the list given below:
[[101,'Simran',98],[102,'Rajveer',95],[103,'Samar' ,96],[104,'Shakti',88]]
11) Write a program in Python Pandas to create the following DataFrame toppers
from a Dictionary:
T_NO Name PB1 PB2
1 Pavan 90 80
2 Sugandha 85 75
3 Pulkita 70 72
4 Sahil 69 71
Perform the following operations on the DataFrame :
i) Add both the marks from PB1 and PB2 of a student and assign to column
“Final”.
ii) Add a new row with values (5, Raman,60,85)
iii) Delete the column PB2
12) Write a program in Python Pandas to create the following DataFrame Student
from Dictionary of Series:
13) Observe the following code and write statements for the below given questions:
import pandas as pd
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
17) Write a program to read from a CSV file name “emp.csv”. and create a dataframe
from it but your dataframe should not use file column header rather should use
own column heading as ID, Name, Designation, Salary. Also print the maximum
salary given to an employee.
18)
Write a python code with the following specifications.
i) Create four dictionaries naming emp1, emp2, emp3, emp4 to store the details
of four employees of the month with emp_no, name, salary.
ii) Create a dataframe from those dictionaries and display it.
iii) Create a series with the employee name from the created dataframe and
display the same.
iv) Display the sales man who earns less than 45000.
v) Increase the salary by 3% and display the same.
i) Find all rows with the label “Apple”. Extract all columns.
22) Write a Python code to create the following dataframe books suing Python
Pandas. Use any method of dataframe creation that you have learnt:
Give index as „B1‟, „B2‟, „B3‟, „B4‟
23) Mr. Sam, a data analyst has designed the DataFrame df that contains data about
Computer Olympiad with „CO1‟, „CO2‟, „CO3‟, „CO4‟, „CO5‟ as indexes
shown below. Answer the following questions:
24) Write python code to create the following dataframe books using python
pandas. Use any method of dataframe creation that you have learnt:
Given index as ‘A1’,’A2’,’A3’.
*******************************