![](/img/trans.png)
[英]numpy.core._exceptions.UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U20'), dtype('int64')) -> None PYHTON
[英]ufunc 'add' did not contain a loop with signature matching types (dtype('<U19'), dtype('int64')) -> None
我正在嘗試使用 pandas 讀取 csv。這樣做時我收到以下錯誤:“ufunc 'add' 不包含具有簽名匹配類型的循環 (dtype('<U19'), dtype('int64')) - > 無”有人可以解釋為什么我得到這個以及它是什么意思嗎? 謝謝。
try:
now = dt.datetime.now()
print (now.strftime("%Y-%m-%d %H:%M:%S") + " : Reading data from the File now.")
file_to_upload = pd.read_csv('D:/data/Desk/de-project/users.csv', delimiter=',')
df_short = file_to_upload.head()
now = dt.datetime.now()
print(now.strftime("%Y-%m-%d %H:%M:%S") + df_short)
except Exception as e:
now = dt.datetime.now()
print(now.strftime("%Y-%m-%d %H:%M:%S") + ' : Error getting file: ' + str(e))
我已經想通了。 問題出在印刷品 function 上:
print(now.strftime("%Y-%m-%d %H:%M:%S") + df_short)
在這里,'+' 運算符導致了問題,因為我試圖打印時間戳和 df。 這是不合邏輯的,因為您不能使用 df 添加時間戳值。
在這樣做的路上:
print(now.strftime("%Y-%m-%d %H:%M:%S") + 'Printing df')
print(df_short)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.