Ch-1_Python_Pandas-_I(Series)_Programs[1]
Ch-1_Python_Pandas-_I(Series)_Programs[1]
Informatics Practices
Std -12
Chapter-1
Python Pandas- I
Series
Programs
Program-1
Create a simple Pandas Series from a list:
a = [1, 7, 2]
Program-2 1. Create a Empty Series
Write a code to create a empty Series object i.e. having no values.
Assume that Pandas as alias name pd
Input
Output
Program-3 2. Creating a Non- Empty Series
Write a code to create a Series object using the python sequence
[4,6,8,10]. Assume that Pandas as alias name pd
Input
Output
Program-4
Input
Output
Program-5
Input
Output
Program-6
Input
Output
Program-7
Input
Output
Program-8
Output
Program-9
Write a program to create a Series object with data of no. students
as 40,41,39,42 for the section A,B,C,D of class 12 in your school .
Input
Output
Program-10
Output
Program-11
Output
Program-12
A python list namely section names(‘A’, ‘B’, ’C’, ‘D’) of class12 in your
school. Another list Conutri stores the contribution made by these
students to a charity fund enclosed by the school. Write a code to
create a series object that contribution amount as the values and
the section names as the indexes.
Input
Output
Program-13
Input
Output
Program-13
Input Output
Program-14
Input Output
Program-15
Sequence section and contri1 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 series object that stores the
contribution amount as the values and the section names as the
indexes with data type as float32
Input
Program-15
Output
Program-16
Input Output
Program-18
Consider the series object s1that stores section names (‘A’, ‘B’, ‘C’,
‘D’) and contribution made by them respectively (6700, 5600,
5000,5200) for a charity. Write a code to modify the amount of
section ’A’ as 7600 and for sections ‘C’ & ‘D’ as 7000. print the
changed series object.
Input
Output
Program-19
Input
Program-20
Input
Program-21
Input
Output
Program-22
Output
Program-24
Coding Output
Program-27
Consider the below given two code fragments. Will they produce the
same output? Why/Why not?
a) fst=[9,10,11]
ob1=pd.Series(data=fst*2)
print(ob1)
b) fst=pd.Series(data=[9,10,11])
ob2=pd.Series(data=fst*2)
print(ob2)
Coding
Program-28
Output
Program-30
Output
Coding
Output
Program-31
Given are two objects, a list objects namely lst1 and a series object
namely ser1, both are having similar values i.e. 2,4,6,8. Find out the
output produced by following statements:
a) print(lst*2) b) print(ser1*2)
Coding Output
Program-32
Given a series that shows the area of some states in km2. Write code
to find out the biggest and smallest three areas from the given
series. given series has been created like this.
Ser1=pd.Series([34567, 890, 450, 67892, 34677, 78902, 25611,
678291,637632, 25723, 2367, 11789, 345, 256517])
Coding
Output
Program-33
From the Ser1 of areas (given earlier that stores areas of states in
km2) , find out the areas that are more than 50000 km2
Ser1=pd.Series([34567,890,450,67892,34677,78902,25611,678291,6
37632,25723,2367,11789,345,256517])
Coding
Output
Program-34
Coding Output
Program-35 Write a program to sort the values of series object s1 in
descending order of its indexes and store it into series
object s3.
Coding Output
Program-36 Given a series object s4. Write a program to change the
values at its 2nd row(index1) and 3rd row to 8000.
Coding
Output
Program-37
Given a series object s5. Write a program to store the squares of the
series values in the object s6. Display s6’s values which are >15
Output
Coding