I have following code:
df['time'] = (pd.to_datetime(df['unix_time'], unit='s')) df['time'] = (pd.to_datetime(df['unix_time'], unit='s',tz='Europe/Vienna'))
First line runs but when I try to set the new timestamp as a local time for that timezone I get an error as – **
to_datetime() got an unexpected keyword argument ‘tz’**
Thanks
Advertisement
Answer
pd.to_datetime(df['unix_time'], unit='s').tz_localize('Europe/Vienna')
or alternatively
pd.to_datetime(df['unix_time'], unit='s',utc=True).tz_convert('Europe/Vienna')