Python 熊猫:“df.dtypes”的最后一行是“dtype:object”,这是什么意思,它是谁的类型?
这段代码构造了一个简单的数据帧Python 熊猫:“df.dtypes”的最后一行是“dtype:object”,这是什么意思,它是谁的类型?,python,pandas,Python,Pandas,这段代码构造了一个简单的数据帧 df = pd.DataFrame([[0, 1], [0, 1], [0, 1]]) df.dtypes 输出是 0 int64 1 int64 dtype: object 输出的最后一行是dtype:object,这意味着什么,它是谁的类型?这意味着df返回的序列。dtypes具有dtype对象,因为至少序列的obne类型是对象: 如果仅测试整数系列,则返回int64,并在系列的数据下显示此信息: print (s1.apply(type))
df = pd.DataFrame([[0, 1], [0, 1], [0, 1]])
df.dtypes
输出是
0 int64
1 int64
dtype: object
输出的最后一行是
dtype:object
,这意味着什么,它是谁的类型?这意味着df返回的序列
。dtypes
具有dtype对象
,因为至少序列的obne类型是对象
:
如果仅测试整数系列
,则返回int64
,并在系列
的数据下显示此信息:
print (s1.apply(type))
MPG <class 'numpy.dtype'>
Cylinders <class 'numpy.dtype'>
Displacement <class 'numpy.dtype'>
Horsepower <class 'numpy.dtype'>
Weight <class 'numpy.dtype'>
Acceleration <class 'numpy.dtype'>
Year <class 'numpy.dtype'>
Origin <class 'pandas.core.dtypes.dtypes.CategoricalD...
dtype: object
s = pd.Series([1,2])
print (s)
0 1
1 2
dtype: int64
print (s.dtype)
int64
s = pd.Series([1,2])
print (s)
0 1
1 2
dtype: int64
print (s.dtype)
int64