Pandas Series.dtype


Pandas Series.dtype property

In this tutorial, we'll go through examples for the Pandas Series.dtype property, which returns the dtype object of the underlying Series data.


Examples for Series.dtype 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.dtype 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.dtype

# Display the result
print(dtype)

Output

int64

2. 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.dtype 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.dtype

# Display the result
print(dtype)

Output

object

Python Libraries