Pandas Series.dtypes
Pandas Series.dtypes property
In this tutorial, we'll go through examples for the Pandas Series.dtypes property, which returns the dtype object of the underlying Series data.
Examples for Series.dtypes property
1. Getting dtype of the given Series
In the following program, we take a Series object in series_data, get the dtype of the data in this Series object using Series.dtypes property, and print the dtype to output.
Python Program
import pandas as pd
# Create a Pandas Series
series_data = pd.Series([10, 20, 30, 40, 50])
# Get dtype of Series data
dtype = series_data.dtypes
# Display the result
print(dtype)Output
int642. Getting dtype of the Series with mixed type values
In the following program, we take a Series object in series_data, get the dtype of the data in this Series object using Series.dtypes property, and print the dtype to output.
Python Program
import pandas as pd
# Create a Pandas Series
series_data = pd.Series(['apple', 20, 'Abc Complany', 4.452])
# Get dtype of Series data
dtype = series_data.dtypes
# Display the result
print(dtype)Output
object