Interventions_df['From DateTime'] = pd.to_datetime(Interventions_df['From DateTime'], dayfirst = True)
Interventions_df['To DateTime'] = pd.to_datetime(Interventions_df['To DateTime'], dayfirst = True)
ParserError: Unknown string format: 14-09-2021 10:39:00:00
uj5u.com熱心網友回復:
如果你想擺脫這個錯誤,你可以嘗試在 中傳遞format引數pd.to_datetime(),這樣決議器就可以識別str你提供的格式。檢查此方法的檔案以獲取更多詳細資訊和語法詳細資訊,這將有助于您制定此str引數。
uj5u.com熱心網友回復:
時間部分格式不正確10:39:00:00(HH:MM:SS:??)
嘗試:
# Regex to match a correct datetime format
pat = r'(\d{2}-\d{2}-\d{4}\s \d{2}:\d{2}:\d{2})
#
# I rename 'Inteventions_df' to 'df' for readability
#
df['From DateTime'] = \
df['From DateTime'].str.extract(pat, expand=False).astype('datetime64')
df['To DateTime'] = \
df['To DateTime'].str.extract(pat, expand=False).astype('datetime64')
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/313673.html
