DATAFRAME PYTHON
SOLUTIO.....
Â
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)
import pandas as pd
serObj = pd.Series([31, 28, 31, 30], index=["Jan", "Feb", "Mar", "Apr"])
print(serObj)
#Answer 1
print("Answer 1")
serObj["May"] = 31
print(serObj)
#Answer 2
print("Answer 2")
serObj["Feb"] = 29
print(serObj)
#Answer 3
print("Answer 3")
serObj.index = [1, 2, 3, 4, 5]
print(serObj)
#Answer 4
print("Answer 4")
print(serObj[serObj < 31])
OUTPUT


