0% found this document useful (0 votes)
371 views1 page

Problem Solving Using Python: Source Code

Uploaded by

bibinbaiju570047
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)
371 views1 page

Problem Solving Using Python: Source Code

Uploaded by

bibinbaiju570047
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

PROBLEM SOLVING USING PYTHON

Q1) Write the code to create the series ‘serObj’ and answer the questions followed.
Jan 31
Feb 28
Mar 31
Apr 30
i) Write the command to add one row: ‘May’ – 31
ii) Write the command to update Feb to 29
iii) Write the command to change index to 1,2,3,4,5 in place of Jan, Feb, Mar, Apr and May.
iv) Write a command to print a month name having number of days less than 31.
v) Write the output:
(a) print(serObj<30)
(b) print(serObj + 3)

Source code :
i) import pandas as pd
serObj = pd.Series(data=[31,28,31,30],index=['Jan','Feb','Mar','Apr'])
print(serObj)
serObj['May']=31

ii) serObj['Feb']=29

iii) newind=[1,2,3,4,5]
serObj.index=newind
print(serObj)

iv) print(serObj[serObj<31])

v) a) print(serObj<30)
b) print(serObj+30)

1|Page

You might also like