List of all possible data types returned by pandas.DataFrame.dtypes

Viewed 366

I want to know the list of all possible data types returned by pandas.DataFrame.dtypes.

(A) As per https://pbpython.com/pandas_dtypes.html the following are all the possible data types in pandas:

object, int64, float64, bool, datetime64, timedelta, category

(B) This SO answer talks about pandas supporting many more kinds of data types including PeriodDType, CategoricalDtype, etc.

Is it correct to say that (A) represents all possible data types with 'object' doing the heavy lifting for all the additional datatypes not specified (i.e., including for those in (B))?

1 Answers

https://pandas.pydata.org/docs/user_guide/basics.html#dtypes

This should give you the info required. TL-DR; pandas generally supports these numpy dtypes - float, int, bool, timedelta64[ns], datetime64[ns] in addition to the generic object dtype which is a catchall.

However, pandas has been introducing extension dtypes for a while now.

Is it correct to say that (A) represents all possible data types with 'object' doing the heavy lifting for all the additional datatypes not specified (i.e., including for those in (B))?

No, object is primarily there for either string columns or columns with mixed types. The newer ExtensionDtypes seem to be similar to np.dtypes

A pandas.api.extensions.ExtensionDtype is similar to a numpy.dtype object. It describes the data type.

https://pandas.pydata.org/docs/development/extending.html#extending-extension-types

Related