modin.pandas.DataFrame.select_dtypes¶

DataFrame.select_dtypes(include: ListLike | str | type | None = None, exclude: ListLike | str | type | None = None) → DataFrame[source]¶

Return a subset of the DataFrame’s columns based on the column dtypes. At least one of the parameters must be specified, and the include/exclude lists must not overlap.

Parameters:
  • include (Optional[ListLike | type], default None) – A list of dtypes to include in the result.

  • exclude (Optional[ListLike | type], default None) – A list of dtypes to exclude from the result.

Returns:

The subset of the frame including the dtypes in include and excluding the dtypes in exclude. If a column’s dtype is a subtype of a type in both include and exclude (such as if include=[np.number] and exclude=[int]), then the column will be excluded.

Return type:

DataFrame

Examples

>>> df = pd.DataFrame({'a': [1, 2] * 3,
...                    'b': [True, False] * 3,
...                    'c': [1.0, 2.0] * 3})
Copy
>>> df.dtypes  
a      int64
b       bool
c    float64
dtype: object
Copy

Including all number columns:

>>> df.select_dtypes("number")  
   a    c
0  1  1.0
1  2  2.0
2  1  1.0
3  2  2.0
4  1  1.0
5  2  2.0
Copy

Including only bool columns:

>>> df.select_dtypes(include=[bool])  
       b
0   True
1  False
2   True
3  False
4   True
5  False
Copy

Excluding int columns:

>>> df.select_dtypes(exclude=[int])  
       b    c
0   True  1.0
1  False  2.0
2   True  1.0
3  False  2.0
4   True  1.0
5  False  2.0
Copy