#17. WAP in Python to create a DataFrame to store weight, age
and names of 3 people. Print the DataFrame and its transpose.
import pandas as pd
d={'Weight':[75,72,65], \
   'Age':[28,22,32], \
   'Name':['Ashu','Ritesh','Krishan']}
df=pd.DataFrame(d)
print("DataFrame is:
")
print(df)
print("Transpose of
DataFrame is: ")
print(df.T)
DataFrame is: 
   Weight 
Age     Name
0      75  
28     Ashu
1      72  
22   Ritesh
2      65  
32  Krishan
Transpose of DataFrame is:
           0       1       
2
Weight    75     
72       65
Age       28     
22       32
Name    Ashu 
Ritesh  Krishan
>>>
 
 
 
No comments:
Post a Comment