Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 熊猫:“df.dtypes”的最后一行是“dtype:object”,这是什么意思,它是谁的类型?_Python_Pandas - Fatal编程技术网

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