* [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ DataFrame ](../frame.html)
  * pandas.DataF... 

#  pandas.DataFrame.select_dtypes  #

DataFrame.  select_dtypes  (  _ include  =  None  _ , _ exclude  =  None  _ )
[ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/frame.py#L4951-L5093) #

    

Return a subset of the DataFrameâs columns based on the column dtypes.

Parameters  :

    

**include, exclude** scalar or list-like

    

A selection of dtypes or strings to be included/excluded. At least one of
these parameters must be supplied.

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. 

See also

[ ` DataFrame.dtypes  ` ](pandas.DataFrame.dtypes.html#pandas.DataFrame.dtypes
"pandas.DataFrame.dtypes")

    

Return Series with the data type of each column.

Notes

  * To select all _numeric_ types, use ` np.number  ` or ` 'number'  `

  * To select strings you must use the ` object  ` dtype, but note that this will return _all_ object dtype columns 

  * See the [ numpy dtype hierarchy ](https://numpy.org/doc/stable/reference/arrays.scalars.html)

  * To select datetimes, use ` np.datetime64  ` , ` 'datetime'  ` or ` 'datetime64'  `

  * To select timedeltas, use ` np.timedelta64  ` , ` 'timedelta'  ` or ` 'timedelta64'  `

  * To select Pandas categorical dtypes, use ` 'category'  `

  * To select Pandas datetimetz dtypes, use ` 'datetimetz'  ` or ` 'datetime64[ns,  tz]'  `

Examples

    
    
    >>> df = pd.DataFrame({'a': [1, 2] * 3,
    ...                    'b': [True, False] * 3,
    ...                    'c': [1.0, 2.0] * 3})
    >>> df
            a      b  c
    0       1   True  1.0
    1       2  False  2.0
    2       1   True  1.0
    3       2  False  2.0
    4       1   True  1.0
    5       2  False  2.0
    
    
    
    >>> df.select_dtypes(include='bool')
       b
    0  True
    1  False
    2  True
    3  False
    4  True
    5  False
    
    
    
    >>> df.select_dtypes(include=['float64'])
       c
    0  1.0
    1  2.0
    2  1.0
    3  2.0
    4  1.0
    5  2.0
    
    
    
    >>> df.select_dtypes(exclude=['int64'])
           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
    

[ __ previous  pandas.DataFrame.info  ](pandas.DataFrame.info.html "previous
page") [ next  pandas.DataFrame.values  __ ](pandas.DataFrame.values.html
"next page")

__ On this page

  * ` DataFrame.select_dtypes()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.select_dtypes.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.