Thursday, 11 March 2021

Class 12 IP Practical - 14

 14. WAP to show indexes and axes of a DataFrame.


 

import pandas as pd

d={'Ritesh':{'English':85,'Bio':82,'Physics':35,'IP':95,'Chemistry':81}, \

   'Rishabh':{'English':55,'Bio':62,'Physics':55,'IP':85,'Chemistry':91}, \

   'Harshit':{'English':65,'Bio':72,'Physics':75,'IP':91,'Chemistry':71}, \

   'Krishan':{'English':25,'Bio':75,'Physics':45,'IP':93,'Chemistry':61}, \

   'Shailesh':{'English':75,'Bio':82,'Physics':65,'IP':97,'Chemistry':51}}

df1=pd.DataFrame(d)

print("DataFrame is:")

print(df1)

print("Index of DataFrame:")

print(df1.index)

print("Axis of DataFrame:")

print(df1.axes)

>>>

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

DataFrame is:

           Ritesh  Rishabh  Harshit  Krishan  Shailesh

English        85       55       65       25        75

Bio            82       62       72       75        82

Physics        35       55       75       45        65

IP             95       85       91       93        97

Chemistry      81       91       71       61        51

Index of DataFrame:

Index(['English', 'Bio', 'Physics', 'IP', 'Chemistry'], dtype='object')

Axis of DataFrame:

[Index(['English', 'Bio', 'Physics', 'IP', 'Chemistry'], dtype='object'), Index(['Ritesh', 'Rishabh', 'Harshit', 'Krishan', 'Shailesh'], dtype='object')]

>>> 

No comments:

Post a Comment