Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Python Pandas - Return the dtype object of the underlying data
To return the dtype object of the underlying data, use the index.dtype property in Pandas.
At first, import the required libraries −
import pandas as pd
Creating the index −
index = pd.Index(['Car','Bike', 'Shop','Car','Airplace', 'Truck'])
Display the index −
print("Pandas Index...\n",index)
Return the dtype of the data −
print("\nThe dtype object...\n",index.dtype)
Example
Following is the code −
import pandas as pd
# Creating the index
index = pd.Index(['Car','Bike', 'Shop','Car','Airplace', 'Truck'])
# Display the index
print("Pandas Index...\n",index)
# Return an array representing the data in the Index
print("\nArray...\n",index.values)
# Return the dtype of the data
print("\nThe dtype object...\n",index.dtype)
# Return a tuple of the shape of the underlying data
print("\nA tuple of the shape of underlying data...\n",index.shape)
Output
This will produce the following code −
Pandas Index... Index(['Car', 'Bike', 'Shop', 'Car', 'Airplace', 'Truck'], dtype='object') Array... ['Car' 'Bike' 'Shop' 'Car' 'Airplace' 'Truck'] The dtype object... object A tuple of the shape of underlying data... (6,)
Advertisements
