pandas - Convert datetime to "Europe/Paris" -


i have data frame (df) following datetime variable have convert time format "europe/paris"

datetime   2016-05-13 00:00:00 2016-06-14 00:00:01 2016-07-15 12:32:02 2016-05-16 02:34:10 2016-05-17 11:00:04 

i have tried following

import datetime,pytz  df['eutime'] = none df['eutime'] = pytz.timezone("europe/paris").localize(df['datetime'], is_dst=none)  attributeerror: 'series' object has no attribute 'tzinfo' 

can me?

you may need convert datetime dtype first, if use pd.to_datetime:

df['datetime'] = pd.to_datetime(df['datetime']) 

then can use dt.tz_localize:

in [50]: s = s.dt.tz_localize("europe/paris") s  out[50]: 0   2016-05-13 00:00:00+02:00 1   2016-06-14 00:00:01+02:00 2   2016-07-15 12:32:02+02:00 3   2016-05-16 02:34:10+02:00 4   2016-05-17 11:00:04+02:00 name: datetime  , dtype: datetime64[ns, europe/paris] 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -