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

XII IP Board Practical File

Uploaded by

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

XII IP Board Practical File

Uploaded by

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

PRACTICAL FILE PROGRAMS ON SERIES

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

a) Change the Quantity of ‘Pencils’ to 50


b) Increase the Quantity of Erasers by 20
c) Change the quantity of 3rd, 4th and 5th items to 100
d) If the shopkeeper sells each item worth RS. 10/-, then display the total amount collected.
e) The shopkeeper decides to increase the quantity three times for each item and store it in a new
series. Help him to do so. Also rename the indices for the new series.
PRACTICAL FILE PROGRAMS ON DATA FRAMES

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:

Score1 Score2 Score3


Sunil 90 80 78
Gaurav 65 45 56
Piyush 70 90 87
Kartik 80 76 85

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.

Toys Books Uniform Shoes


Andhra 7916 6189 610 8810
Odisha 8508 8208 508 7800
MP 7226 6149 611 9611
UP 7617 6157 457 6457

Display the following details from the above data frame:

1. Aid for Shoes given to different states.


2. Aid for Toys, Books and Uniform given to different states.
3. Aid of Toys given to MP only
4. Aid of different items given to UP.
5. Aid of Uniform and Shoes given to Andhra, Odisha, and MP.
6. Aid of different items given to Andhra and MP
7. Aid of Toys and Uniform given to Odisha and UP.
8. Aid of toys is less than 8000
16. Write a program to create the following data frame where the index of the data frame indicates the
employee number of each employee.

Name Dept Salary Experience


101 Prerna Singh IT 9500 5
0
102 Manish Arora Sales 6000 4
0
103 Tanish Goel HR 8000 7
0
104 Falguni Jain IT 9800 6
0
Do the 105 Kanika HR 8500 8 following given tasks
on the above 0 data frame and
display the 106 Ramandeep Kaur HR 8800 9 updated data frame
after each 0 task:

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.

18. Consider the following dataset:

Create the data frame from the given set of data.


Store the above data frame into CSV file. Do not write the index and column names of the data frame
into the CSV file. The separator is comma

19. Write a program to import the data into a data frame from the CSV file created in Q 18 and display the
dataframe.

PRACTICAL FILE PROGRAMS ON DATA VISUALIZATION

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.

B_NO Name Score1 Score2


1 Sunil Pillai 90 80
2 Gaurav Sharma 65 45
3 Piyush Goel 70 90
4 Kartik Thakur 80 76

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.

Sales( North Region) Sales ( East Region)


April 110 200
May 150 90
June 230 150
July 400 350

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.

22. Create a histogram from given set of data:


Weight measurements for 16 small orders of French Fries ( in grams).
78,72,69,81,63,67,65,75,79,74,71,83,71,79,80,69
Fill each hist with some pattern instead of some color.
Program 1
Write a Python program to create a Pandas Series of marks of four semesters (stored in a list) of a
student.

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)

You might also like