Thursday 11 March 2021

Class 12 IP Practical - 21

 


21. WAP 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,68],'Age':[25,23,21],'Name':['Ram','Raj','Sam']}

Df=pd.DataFrame(d)

print("DataFrame is : ")

print(Df)

print("Transpose of DataFrame is : ")

print(Df.T)

                     

 

>>>

======================= RESTART: C:/Program Files (x86)/Python38-32/IP-21.py ======================

DataFrame is :

   Weight  Age Name

0      75   25  Ram

1      72   23  Raj

2      68   21  Sam

Transpose of DataFrame is :

          0    1    2

Weight   75   72   68

Age      25   23   21

Name    Ram  Raj  Sam

>>> 

 











No comments:

Post a Comment