converting string to datetime in python pandas with multiple date formats in a column.
Dataframe startdate has date values in 'mm-dd-YYYY hh:mm' format and 'mm/dd/YYYY hh:mm' format. I have used following query
df['START_DATE*'] = pd.to_datetime(df['START_DATE*'], format= '%m-%d-%Y hh:mm')
START_DATE* is the column name.giving following
time data '01-01-2016 21:11' does not match format '%m-%d-%Y hh:mm' (match)
hh:mm
does not mean hour:minute
. Try:
df['START_DATE*'] = pd.to_datetime(df['START_DATE*'], format= '%m-%d-%Y %H:%M')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.