#16. WAP to transpose the values of index and columns in a
DataFrame.
import pandas as pd
d={'Hindi':{'Ram':30,'Raj':20,'Sam':25,'John':35},
\
'English':{'Ram':35,'Raj':25,'Sam':22,'John':32},
\
'IP':{'Ram':40,'Raj':45,'Sam':45,'John':48}, \
'Bio':{'Ram':30,'Raj':24,'Sam':25,'John':25}}
df=pd.DataFrame(d)
print("Data Frame is
:")
print(df)
print("Transpose of
Data Frame is :")
print(df.T)
========= RESTART: C:/Program Files
(x86)/Python38-32/IP-16.py ========
Data Frame is :
Hindi
English IP Bio
Ram 30
35 40 30
Raj 20
25 45 24
Sam 25
22 45 25
John 35
32 48 25
Transpose of Data Frame is
:
Ram
Raj Sam John
Hindi 30
20 25 35
English 35
25 22 32
IP 40
45 45 48
Bio 30
24 25 25
>>>
No comments:
Post a Comment