Python Pandas Assignments
Python Pandas Assignments
1. Create a dictionary that stores the mobile names list as value for ‘Mobiles’ key and their price list as
value for ‘Price’ key. Create DataFrame from this dictionary.
2. Create and display a DataFrame from a 2D dictionary,’ Medals’, which stores the winner details as
inner dictionary for “Basketball, Volleyball and Football”.
3. Write a program to create a DataFrame from a list containing dictionaries which contains “Salaries”
and “Incentives” for 4 employees. Employee names should be the row labels.
4. Write code to create DataFrame from a list containing 4 dictionaries, where each dictionary containing
Target and Actual Sales figures of four zonal offices. Give appropriate row labels.
6. Write a code to create DataFrame object using an ndarray that has 5 elements.
7. Write a code to create DataFrame from 2D array (by ndarray) that has 9 elements.
8. Consider two series objects staff and salaries that store number of people in various office branches
and salaries distributed in these branches, respectively. Write a program to create another Series object
that stores average salary per branch and then create a DataFrame object from these Series objects.
9. Write a program to create a DataFrame to store weight, age and names of 3 people. Print the
DataFrame.
a. Write a statement to display Name, Designation and Salary columns from the above employee
DataFrame.
b. Write a statement to display Name and Salary columns from the above DataFrame.
c. Write a statement to display Bonus column only.
d. Write a statement to display all the information from Employee ids ‘E102’ to ‘E104’ (Both are
included)
e. Write a statement to display all information of Employee id ‘E102’ and ‘E105’.
f. Write a statement to display the employee’s name, designation and salary for those having
employee ids as ‘E101′ and ‘E103’.
g. Write a statement to display the employee’s name and bonus for those having employee id as
‘E101′ and ‘E103’.
h. Write a statement to display the Salary of Darpan.
i. Add a column called “City” with the following details : [‘Janak Puri’,’Tilak Nagar’, ‘Shiv
Nagar’, ‘Vikas Puri’, ‘Janak Puri’]
j. Add a column called “Shift” with “Morning” for all the employees.
k. Add a new row with the following details : [‘E106’, ‘Keerat’, ‘Analyst’, 70000, 15000, ‘Tilak
Nagar’, ‘Morning’].
l. Delete column “Shift” from the above dataframe employee.
m. Delete the record with employee id ‘E103’ and ‘E105’.
n. Rename column “Bonus” as “Incentive”.
o. Print the details of youngest employee.
p. Print the details of all clerk from the employee.
q. Print the average Bonus.
r. Print the total salary distributed among the employees.
Python Pandas Assignment – 3
1. Given a DataFrame namely “data”. Write the code for the following commands
2. Given a DataFrame namely “data”. Write the code for the following commands
3. Write the commands for the following statement after analysis the given dataframe ‘batsman’.
4. Consider the following dataframe “Items” storing production in tones and answers the following
questions :