- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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,)
- Related Articles
- Python Pandas - Return the Number of dimensions of the underlying data
- Python Pandas - Return a tuple of the shape of the underlying data
- Python Pandas - Return the number of bytes in the underlying Index data
- Python Pandas - Return the Number of elements in the underlying Index data
- Python - Check if the Pandas Index is of the object dtype
- Return the scalar dtype or NumPy equivalent of Python type of an object
- Python Pandas - Return the frequency object from the PeriodIndex object
- Python Pandas - Return the Timestamp representation of the Period object
- Python Pandas - Return the maximum value of the Timedelta object
- Python Pandas - Return the minimum value of the Timedelta object
- How do StringDtype objects differ from object dtype in Python Pandas?
- Return the string representation of a scalar dtype in Python
- Python Pandas - Return the microseconds from Timedelta object
- Python Pandas - Return the nanoseconds from Timedelta object
- Python Pandas - Return the seconds from Timedelta object

Advertisements