简体   繁体   中英

Time data with gmt does not match format input for pandas conversion

How to convert date time string with GMT into a pandas date time format ?

Here is an example :

#date_time is like 12/Dec/2015:18:25:11 +0100
df['date_time'] = pd.to_datetime(df['date_time'], format="%d/%b/%Y:%I:%M:%S %Z")

Here is the error :

ValueError: time data '12/Dec/2015:18:25:11 +0100' does not match format '%d/%b/%Y:%I:%M:%S %Z' (match)

You'd better check the formatted string:

https://docs.python.org/3/library/datetime.html

Use '%d/%b/%Y:%H:%M:%S %z' instead of '%d/%b/%Y:%I:%M:%S %Z' .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM