Professional Documents
Culture Documents
(Practicals)
Example1: Write a program to create a series object that stores the initial
budget allocated (50000/each for the four quarters of the year: Qtr1 , Qtr2, Qtr3
and Qtr4.
Example 5: Consider the Series object s13 that stores the comtribution of each
section
6700 A
5600 B
5000 C
5200 D
Write code to modify the amount of section ‘A’ as 7600 and for sections ’C’
and ’D’ as 7000. Print the changed object.
B 5600
C 5000
D 5200
Write a program to display which sections made a contribution more than
rupees 5500/-
Example 9: Create and display a Data Frame from a 2D dictionary, Sales, which
stores the quarterly sales as inner dictionary for two years, as shown below:
Sales={‘yr1’ : {‘Qtr1’: 34500,’Qtr2’: 5600,’Qtr3’: 47000,’Qtr4’: 49000},
‘yr2’ : {‘Qtr1’: 44900, ‘Qtr2’: 46100,’Qtr3’: 57000,’Qtr4 ’: 59000}
Example 12: Write a program to create a Data Frame from a 2D array as shown
below:
(iii)>>> df . i loc[2:5,0:4]
Example 17: Will the previous program reflect the renamed indexes and
columns’ names in the dataframe sale Df ? Make changes in the previous
program so that dataframe sale Df has the changed indexes and columns.
Example 18 : Given a series that stores 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,256711,678291,
637632,25723,2367,11789,345,256517])
Example 19 : Given a Series object s5.Write a program to calculate the cubes of
the Series values.
Example 19 : Given a Series Object s5. Write a program to store the squares of
the Series values in object s6. Display s6’s values which are > 15.
Example 20 : Write a program to display no. of rows and columns in the
DataFrame df.