pandas.DataFrame.dtypes返回的所有可能数据类型的列表

2024-10-03 00:27:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道pandas.DataFrame.dtypes返回的所有可能数据类型的列表

(A)根据https://pbpython.com/pandas_dtypes.html,以下是熊猫中所有可能的数据类型:

对象,int64,float64,bool,datetime64,timedelta,类别

(B)This SO answer谈论熊猫支持更多种类的数据类型,包括PeriodType、CategorialdType等

(A)表示所有可能的数据类型,而“object”负责所有未指定的附加数据类型(即,包括(B)中的数据类型),这样说是否正确


Tags: 对象httpscomdataframepandas列表htmltimedelta
1条回答
网友
1楼 · 发布于 2024-10-03 00:27:41

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

这将为您提供所需的信息。TL-DR;pandas通常支持这些numpy数据类型-float, int, bool, timedelta64[ns], datetime64[ns] ,除了泛型object数据类型之外,泛型object数据类型是一种通用类型

然而,pandas引入扩展数据类型已有一段时间了

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))?

否,object主要用于字符串列或混合类型的列。较新的ExtensionType似乎类似于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

相关问题 更多 >