DataFrame.select_dtypes

DataFrame.select_dtypes(include=None, exclude=None) DataFrame[source]

Return a subset of the DataFrame’s columns based on the column dtypes.

Compatible with :pandas_api_docs:`pandas.DataFrame.select_dtypes`

Returns

opensearch_py_ml.DataFrame

DataFrame contains only columns of selected dtypes

Examples

>>> from tests import OPENSEARCH_TEST_CLIENT
>>> df = oml.DataFrame(OPENSEARCH_TEST_CLIENT, 'flights',
... columns=['AvgTicketPrice', 'Dest', 'Cancelled', 'timestamp', 'dayOfWeek'])
>>> df.dtypes
AvgTicketPrice           float64
Dest                      object
Cancelled                   bool
timestamp         datetime64[ns]
dayOfWeek                  int64
dtype: object
>>> df = df.select_dtypes(include=[np.number, 'datetime'])
>>> df.dtypes
AvgTicketPrice           float64
timestamp         datetime64[ns]
dayOfWeek                  int64
dtype: object