Python | Pandas Index.dtype
Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects.
Pandas Index.dtype
attribute return the data type (dtype) of the underlying data of the given Index object.
Syntax: Index.dtype
Parameter : None
Returns : dtype
Example #1: Use Index.dtype
attribute to find the dtype of the underlying data of the given Index object.
import pandas as pd
idx = pd.Index([ 'Jan' , 'Feb' , 'Mar' , 'Apr' , 'May' ])
print (idx)
|
Output :
Now we will use Index.dtype
attribute to find the data type of the underlying data of the given series object.
result = idx.dtype
print (result)
|
Output :
As we can see in the output, the Index.dtype
attribute has returned object
as the data type of the underlying data of the given Index object.
Example #2 : Use Index.dtype
attribute to find the dtype of the underlying data of the given Index object.
import pandas as pd
idx = pd.Index([ 100 , 200 , 142 , 88 , 124 ])
print (idx)
|
Output :
Now we will use Index.dtype
attribute to find the data type of the underlying data of the given series object.
result = idx.dtype
print (result)
|
Output :
As we can see in the output, the Index.dtype
attribute has returned int64
as the data type of the underlying data of the given Index object.
Last Updated :
20 Feb, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...