Setting timezone for timestamp data in pandas dataframe
<p>I have a frequently changing pandas dataframe of data that looks like this:</p>

<pre><code>         date name  time       timezone
0  2016-08-01  aaa  0900     Asia/Tokyo
1  2016-08-04  bbb  1200  Europe/Berlin
2  2016-08-05  ccc  1400  Europe/London
</code></pre>

<p>The date, time and timezone refer to a delivery date that is often for an overseas location, with the name being the name of the client company.</p>

<p>The plan is to take this data and create a <code>datetime_local</code> column that incorporates the time zone shown in the <code>timezone</code> column of dataframe. Then from that I want to add a column <code>datetime_london</code> that contains that date and time, but expressed in terms of the time and date in London.</p>

<p>I have got most of the way there but when calling <code>tz_localize</code> I end up with a <code>ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()</code> which suggests to me that I'm not treating the column with the timezone correctly.</p>

<p>Any suggestions as to how to proceed?</p>

<pre><code>mydf = pd.DataFrame(data={'date':['2016-08-01','2016-08-04','2016-08-05'],
                          'time':['0900','1200','1400'],
                          'timezone':['Asia/Tokyo','Europe/Berlin','Europe/London'],
                          'name':['aaa','bbb','ccc']}
)
print(mydf)
mydf["datetime"] = mydf["date"].map(str) + " " + mydf["time"]
mydf.datetime = pd.to_datetime(mydf.datetime)
mydf.index = mydf.datetime
print(mydf)
mydf["datetime_local"] = mydf.datetime
mydf.datetime_local.tz_localize(mydf.timezone)
</code></pre>