Pandas DataFrame select_dtypes() Method with examples

Spread the love

Pandas select_dtypes() method returns a subset of the DataFrame’s columns based on the column dtypes. You can include or exclude columns based on their dtypes.

Let’s read a dataset.

import pandas as pd

url = ''
df = pd.read_csv(url)

We can check the data types of each columns using the dtype method.


Including Columns –

Let’s say that you want to select all integer columns from your dataframe.


Excluding Columns –

You can also exclude columns using the exclude parameter. Let’s say you want to exclude all integer and float columns.


Rating: 1 out of 5.

Leave a Reply