When I use pandas read_csv to read a column with a timezone aware datetime (and specify this column to be the index), pandas converts it to a timezone naive utc
I adopted the dateutil
technique earlier today but have since switched to a faster alternative:
date_parser = lambda ts: pd.to_datetime([s[:-5] for s in ts]))
Edit:
s[:-5]
is correct (screenshot has error)
In the screenshot below, I import ~55MB of tab-separated files. The dateutil
method works, but takes orders of magnitude longer.
This was using pandas 0.18.1 and dateutil 2.5.3.
EDIT This lambda function will work even if Z-0000
suffix is missing...
date_parser = lambda ts: pd.to_datetime([s[:-5] if 'Z' in s else s for s in ts])