w3resource

Pandas DataFrame: select_dtypes() function

DataFrame - select_dtypes() function

The select_dtypes function is used to get a subset of the DataFrame’s columns based on the column dtypes.

Syntax:

DataFrame.select_dtypes(self, include=None, exclude=None)

Parameters:

Name Description Type/Default Value Required / Optional
include, exclude A selection of dtypes or strings to be included/excluded. At least one of these parameters must be supplied. scalar or list-like Required

Returns: DataFrame
The subset of the frame including the dtypes in include and excluding the dtypes in exclude.

Raises: ValueError
  • If both of include and exclude are empty
  • If include and exclude have overlapping elements
  • If any kind of string dtype is passed in.

Example:


Download the Pandas DataFrame Notebooks from here.

Previous: DataFrame - dtypes property
Next: DataFrame - values property



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/pandas/dataframe/dataframe-select_dtypes.php