![](/img/trans.png)
[英]How to solve type object 'Series' has no attribute '_get_dtypes' error using modin.pandas?
[英]Series Error when using .dtypes() for pandas
我對 Python / Pandas 比較陌生,我正在嘗試打印數據框中每一列的值類型。 但是,當我嘗試使用 the.dtypes() function 時,我遇到了一系列錯誤。
這是我正在使用的一些代碼:
file = pd.read_csv('Nudge.csv', sep=",")
data = pd.DataFrame({'SR_ID': file['SR ID'], 'On_Time_%': file['On-Time %'], '#_Tardy': file['# Unex Tardy'],
'Tardy_Rank': file['Tardy Rank']})
new_data = data.sort_values(by='On_Time_%', ascending=True)
# print(new_data)
print(data.dtypes())
TypeError: 'Series' object is not callable
只需使用data.dtypes
而不是data.dtypes()
,因為它是一個屬性,沒有 function。
這將返回如下內容:
ID object
Year object
Month object
Amount object
dtype: object
dtypes 不是 function 而是一個變量。 應該這樣稱呼
print(data.dtypes)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.