XII IP Board Practical File
XII IP Board Practical File
1. Write a Python program to create a Pandas Series of marks of four semesters (stored in a list) of a
student.
2. Write a Python program to create a Pandas Series object using a dictionary that stores the number of
students in each section of class 12 in your school.
3. Write a Python program to create a Pandas Series object from a nd array which stores first five
multiples of 5. Assign index ‘a’, ’e’, ‘I’, ‘o’, ‘u’ to each element of the series.
4. Write a Python program which creates a Pandas Series object that stores the initial budget allocated
(RS. 50000/- each) for the four quarters of the year : Qtr1, Qtr2, Qtr3, Qtr4.
Also print a report of following attributes for the above created series- Data type,Number of Elements
in the series, Values in the series, Shape, Number of bytes, Number. of dimensions, Item size, Has
NaNs, Is Empty etc.
5. Sequences section and contri store the section names ( ‘A’, ‘B’, ‘C’, ‘D’, E’) and contribution made by
them respectively (6700, 5600, 5000, 5200, nil) for a charity. Your school has decided to donate as
much contribution as made by each section, i.e., the donation will be doubled.
Write code to create the series object that stores the contribution amount as the values and the
section names as the indices with datatype as float32.
6. Write a program to create a Pandas Series which contains the number of days in the first six months of
a year. The name of month is stored as index of the series. The program also displays the name of the
months having 31 days.
7. Number of students in classes 11 and 12 in three streams (‘Science’, ‘Commerce’, and ‘Humanities’)
are stored in two Series objects c11 and c12. Write a code to find total number of students in classes
11 and 12, streamwise.
8. Object 1 Population stores the details of population in four metro cities of India. AvgIncome stores
the total average income reported in previous year in each of these metros. Calculate income per
capita for each of these metro cities.
9. Create a Pandas series from the following given list of areas of some states in km2.
[ 34567, 25723, 67892, 1000, 245981, 678291, 30000, 11785, 653452, 40001]
a) Display the series in ascending order of area.
b) Display the series in descending order of area.
c) Display the biggest 3 areas from the series
d) Display the smallest three areas from the series.
e) Display the areas which are more than 50000km2
10. Create the following data series which stores the quantity of items in a shop for various items.
Quantity
Pencils 25
Eraser 40
Gel Pen 45
Ball Pen 30
Fountain Pen 60
Notebooks 35
Display the series after performing following changes in the given series
11. Write a program to create a data frame to store the Quarterly sales(Quarter1, Quarter2, Quarter3,
Quarter4) of various items in the stock in the year 2020. The name of items is stored as index of the
data frame. (Use Nested lists to create data frame)
12. Write a program to create a Data Frame to store the Name, age, and marks of students. The roll
numbers of the students are index of the data frame Use dictionary of lists to create the data frame.
13. Write a program to create the following data frame using pandas’ series:
14. Create a data frame class12 which store the list of various sections in class 12, the number of students
and the class teacher name. Write a menu driven program which will display the following
information about the above data frame.
1. Row labels
2. Column labels
3. Data type of each column
4. Number of total elements in the data frame
5. Dimensions of the data frame
6. Shape of the data frame
7. Check the data frame contain any empty values or not
8. Transpose of the data frame
15. Write a program to create a data frame aid that stores the aid by NGOs for different states.
1. Input values Name, Department, Salary, and Experience for a new employee with employee
number 107. Add this new record as the last row of the data frame.
2. Display the top 3 rows of the data frame.
3. Increase the salary of employee numbers 102 and 103 by 5000
4. Change the Department of ‘Kanika’ to Marketing
5. Display the details of employees of ‘IT’ Department.
6. Add a new column Leaves to the existing data frame and assign value 0 for all rows.
7. Add a new column Bonus and assign value 5000 for each employee.
8. Display last 4 rows of the above data frame
9. Delete the column ‘Leaves’ from the above data frame permanently
10. Delete the record number 106 and 107 permanently from the above data frame.
17. Create the following data frame for HCL Corp. Ltd to store the targeted and achieved sales for the four
regions:
Targeted Achieved
North 56000 58000
South 70000 68000
East 75000 78000
West 60000 61000
Write a program to extract the data from data frame row wise using iterrows() and columnwise using
iteritems(). Also change the row names as ‘ZoneA’, ‘ZoneB’, ‘ZoneC’ and ‘ZoneD’ and column names
as ‘Target’ and ‘Sales’ and display the data frame.
19. Write a program to import the data into a data frame from the CSV file created in Q 18 and display the
dataframe.
20. Write a program in Python Pandas to create the following DataFrame “batsman” from a Dictionary.
Draw line charts to show the plotting of ‘Score1’ and ‘Score 2’ for all batsmen. Put suitable legends
and titles. Specify different colours and line styles of your choice for both the plottedlines. Change
font size of the titles to 15 and colour to green.
21. Bajaj Auto has given his sales figures of his North and East Region for the 1st quarter of the financial
year 2023. Present the same in the form of bar graph.
Write a program to represent the above given data as a data frame (consider month as indexes)
andthen print the graph. Put months as x axis and sales ( of both region) as y axis. Also, include
other formatting of the chart and save the chart.
import pandas as pd
m=[82,84,85,88]
i=['Sem1', 'Sem2', 'Sem3', 'Sem4']
marks=pd.Series(data=m, index=i)
print(marks)
OUTPUT
PROGRAM 2
Write a Python program to create a Pandas Series object using a dictionary that stores the number
of students in each section of class 12 in your school
Write a Python program to create a Pandas Series object from a nd array which stores first five
multiples of 5. Assign index ‘a’, ’e’, ‘I’, ‘o’, ‘u’ to each element of the series
import pandas as pd
import numpy as np
arr=np.arange(5,30,5)
s=pd.Series(arr,index=['a','e','i','o','u'])
print(s)