Python | Pandas Index.dtype_str
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_str
attribute return the data type (dtype) of the underlying data of the given Index object as a string.
Syntax: Index.dtype_str
Parameter : None
Returns : dtype as a string
Example #1: Use Index.dtype_str
attribute to find the dtype of the underlying data of the given Index object as a string.
import pandas as pd
idx = pd.Index([ 'Jan' , 'Feb' , 'Mar' , 'Apr' , 'May' ])
print (idx)
|
Output :
Now we will use Index.dtype_str
attribute to find the data type of the underlying data of the given series object as a string.
result = idx.dtype_str
print (result)
|
Output :
As we can see in the output, the Index.dtype_str
attribute has returned the data of the underlying data of the given Index object as a string.
Example #2 : Use Index.dtype_str
attribute to find the dtype of the underlying data of the given Index object as a string.
import pandas as pd
idx = pd.Index([ 100 , 200 , 142 , 88 , 124 ])
print (idx)
|
Output :
Now we will use Index.dtype_str
attribute to find the data type of the underlying data of the given series object as a string.
result = idx.dtype_str
print (result)
|
Output :
As we can see in the output, the Index.dtype_str
attribute has returned the data of the underlying data of the given Index object as a string.
Last Updated :
20 Feb, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...