我想将此数据帧从此字符串转换为可用的日期时间格式
01/May/2016:06:38:13 +0100
我目前正在使用Python V 3.5.1 :: Anaconda 4.0.0(64-bit)
答案 0 :(得分:1)
import time
from time import mktime
from datetime import datetime
df.time = df.time.apply(lambda x: datetime.fromtimestamp(mktime(time.strptime(x, '%d/%b/%Y:%I:%M:%S %z'))))
http://pandas.pydata.org/pandas-docs/stable/generated/pandas.to_datetime.html https://docs.python.org/3.5/library/datetime.html#strftime-and-strptime-behavior How do you convert a Python time.struct_time object into a datetime object?
答案 1 :(得分:1)