Friday, September 30, 2022

Series Attribute - Class 12 IP Notes

 #Series Attributes

'''

Function   ()    => len(L)

method      ()    => S.head(), S.tail(), pd.Series()

attribute   without bracket  =>  S.index, S.shape, S.size, S.dtype


'''

import pandas as pd

L=[10,20,30,40,None]

I=['a','b','c','d','e']

S=pd.Series(L,I)

print(S)

print(S.index)  #print all index of series in list 

print(S.shape)  #shape return the number of elements in series including NaN

                #in tuple (5,)


print(S.size)   #size return the number of elements in series including NaN

                #in integer  = 5

print(S.dtype)  #return the data type of series i.e float64


L1=[10,20,30]

S1=pd.Series(L1)

print(S1.dtype) #return the data type of series i.e int64

print(S1.empty) #return True if series is empty otherwise False i.e False

S2=pd.Series()

print(S2.empty) #return True if series is empty otherwise False i.e True


print(S.hasnans) #It returns True if there are any NaN values,

                    #otherwise returns false.

print(S1.hasnans)#It returns True if there are any NaN values,

                    #otherwise returns false.





















No comments:

Post a Comment