0% found this document useful (0 votes)
100 views

Python Pandas Assignments

CBSE Class XII - Informatics Practices (065) assignments
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views

Python Pandas Assignments

CBSE Class XII - Informatics Practices (065) assignments
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Class : XII – IP

Python Pandas Assignment – 1

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.

5. Write a program to create a DataFrame from a 2D array as shown below:


11 22 33
44 55 66
77 88 99

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.

10. Write a code to Create DataFrame from the below table.


Roll No Name Class Percentage
1 Raj XII 89
2 Amit XII 98
3 Naman XII 78
4 Yash XII 85
5 Saiyam XII 80
Python Pandas Assignment – 2

1. Given a DataFrame namely “employee” that stores the details of employees:

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

a) Find all rows with the label “Pencil”. Extract


all columns
b) List products with count more than 25.
c) List single True or False to signify if all
prices are more than 100 or not.
d) List 2nd , 3rd and 4th row.
e) List only the columns Company and Price.
f) List only rows with labels ‘Pencil’ and ‘Pen’

2. Given a DataFrame namely “data”. Write the code for the following commands

a) Change the Eraser count as 15 instead of 25.


b) Rename the index “Scale” as “Wooden Scale”.
c) Change all the row label as ‘Product 1′, Product 2’,
‘Product 3’, ‘Product 4’.
d) Change all the column name as ‘Discount’, ‘Total’
e) Add a new row ‘Product 5’ with value 10 and 100.

3. Write the commands for the following statement after analysis the given dataframe ‘batsman’.

a) Add both the scores of a batsman and


assign to column “Total”.
b) Display the highest score in both Score 1
and Score 2 of the DataFrame.
c) Display the DataFrame.

4. Consider the following dataframe “Items” storing production in tones and answers the following
questions :

a) Total production for each state.


b) Total production for each item type.
c) How many States produces Wheat?
d) Print details of the state with
maximum Rice production.

You might also like