Tutorials References Exercises Videos Menu
Free Website Get Certified Upgrade

Pandas DataFrame select_dtypes() Method

❮ DataFrame Reference


Return a DataFrame with only the columns with the dtype 'int64':

import pandas as pd

df = pd.read_csv('data.csv')

newdf = df.select_dtypes(include='int64')
Try it Yourself »

Definition and Usage

The select_dtypes() method returns a new DataFrame that includes/excludes columns of the specified dtype(s).

Use the include parameter to specify the included columns, or use the exclude parameter to specify which columns to exclude

Note: You must specify at least one of the parameters include and/or exclude, or else you will get an error.


dataframe.select_dtypes(include, exclude)


The parameters are keyword arguments.

Parameter Value Description
include string|list Which column(s) to include in the result. Required if the exclude parameter is not present.
exclude string|list Which column(s) to exclude from the result. Required if the include parameter is not present.

Return Value

a Pandas DataFrame with the included columns and without the excluded columns.

❮ DataFrame Reference