Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.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 属性错误:';数据帧';对象没有属性';获取数据类型计数';_Python_Pandas_Dataframe - Fatal编程技术网

Python 属性错误:';数据帧';对象没有属性';获取数据类型计数';

Python 属性错误:';数据帧';对象没有属性';获取数据类型计数';,python,pandas,dataframe,Python,Pandas,Dataframe,我想使用get\u dtype\u counts()方法查看数据帧中数据类型的计数,但它给出了错误。请帮忙 import pandas as pd import numpy as np df = pd.DataFrame(np.arange(5)) df 输出 0 0 0 1 1 2 2 3 3 4 4 错误 df.get_dtype_counts() AttributeError Traceback (

我想使用
get\u dtype\u counts()
方法查看数据帧中数据类型的计数,但它给出了错误。请帮忙

import pandas as pd
import numpy as np

df = pd.DataFrame(np.arange(5))
df
输出

    0
0   0
1   1
2   2
3   3
4   4
错误


df.get_dtype_counts()

AttributeError                            Traceback (most recent call last)
<ipython-input-9-aa9a46562585> in <module>()
      1 df = pd.DataFrame(np.arange(5))
----> 2 df.get_dtype_counts()
      3 # df

/usr/local/lib/python3.6/dist-packages/pandas/core/generic.py in __getattr__(self, name)
   5272             if self._info_axis._can_hold_identifiers_and_holds_name(name):
   5273                 return self[name]
-> 5274             return object.__getattribute__(self, name)
   5275 
   5276     def __setattr__(self, name: str, value) -> None:

AttributeError: 'DataFrame' object has no attribute 'get_dtype_counts'

df.get\u dtype\u counts()
AttributeError回溯(最近一次呼叫上次)
在()
1 df=局部数据帧(np.arange(5))
---->2 df.get_dtype_counts()
3#df
/usr/local/lib/python3.6/dist-packages/pandas/core/generic.py in____getattr___(self,name)
5272如果自身信息轴可容纳标识符且容纳名称(名称):
5273返回自我[姓名]
->5274返回对象。\uuuu getattribute\uuu74(self,name)
5275
5276定义设置属性(self,名称:str,值)->无:
AttributeError:“DataFrame”对象没有“get\u dtype\u counts”属性
.get\u dtype\u counts()
是,使用
.dtypes.value\u counts()
代替

In [20]: import pandas as pd
    ...: import numpy as np
    ...:
    ...: df = pd.DataFrame(np.arange(5))

In [21]:

In [21]: df.dtypes.value_counts()
Out[21]:
int64    1
dtype: int64
.get\u dtype\u counts()
自0.25.0版以来已被弃用


请考虑解释你的代码和它将如何帮助,以便其他人可以从中受益。