pandas dtypes object 不是 string

Columns with mixed types are stored with the object dtype

object包含了str

Kind of Data

Data Type

Scalar

Array

String Aliases

tz-aware datetime

DatetimeTZDtype

Timestamp

arrays.DatetimeArray

'datetime64[ns, <tz>]'

Categorical

CategoricalDtype

(none)

Categorical

'category'

period (time spans)

PeriodDtype

Period

arrays.PeriodArray 'Period[<freq>]'

'period[<freq>]',

sparse

SparseDtype

(none)

arrays.SparseArray

'Sparse''Sparse[int]''Sparse[float]'

intervals

IntervalDtype

Interval

arrays.IntervalArray

'interval''Interval''Interval[<numpy_dtype>]''Interval[datetime64[ns, <tz>]]''Interval[timedelta64[<freq>]]'

nullable integer

Int64Dtype, …

(none)

arrays.IntegerArray

'Int8''Int16''Int32''Int64''UInt8''UInt16''UInt32''UInt64'

nullable float

Float64Dtype, …

(none)

arrays.FloatingArray

'Float32''Float64'

Strings

StringDtype

str

arrays.StringArray

'string'

Boolean (with NA)

BooleanDtype

bool

arrays.BooleanArray

'boolean'


Python有一系列内建的对象类型,开发人员也可以根据需求创建自定义的对象类型。 Python常用的内建对象类型有:数字(Number)、字符串(String)、列表(List)、元组(Tuple)、字典(Dictionary),称为基本对象类型1。Python中的对象类型可以通过一些特殊方法进行转换,例如__int__、float、str、__list__等2。在Python的世界中,object是父子关系的顶端,所有的数据类型的父类都是它;type是类型实例关系的顶端,所有对象都是它的实例的3。https://www.zhihu.com/question/38791962