1 回答

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超3個(gè)贊
嘗試:
import pandas as pd
# Read excel file
date_series_data = pd.read_csv(filepath)
# 'Date' is the column name which has date entries
# I have set time format as YDM. You can change it to other using dt.strftime
date_type_one = pd.to_datetime(date_series_data['Date'], errors='coerce', format='%Y-%d-%m %H:%M:%S').dt.strftime('%Y-%d-%m')
date_type_two = pd.to_datetime(date_series_data['Date'], errors='coerce', format='%d-%m-%Y').dt.strftime('%Y-%d-%m')
date_series_data['Date'] = date_type_one.fillna(date_type_two)
date_series_data.head()
添加回答
舉報(bào)