簡體   English   中英

AttributeError: 'DataFrame' object 沒有屬性 'get_dtype_counts'

[英]AttributeError: 'DataFrame' object has no attribute 'get_dtype_counts'

我想使用get_dtype_counts()方法查看 DataFrame 中數據類型的計數,但它給出了錯誤。 請幫忙。

import pandas as pd
import numpy as np

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

Output

    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'
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_dtype_counts()自版本 0.25.0 起已棄用

在此處輸入圖像描述

.get_dtype_counts() 自 0.25.0 起已棄用,請改用.dtypes.value_counts()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM