title: How can I use timezone as GMT-5:00 to convert timestamps in Python?
body: <p>This question was flagged as already answered, but it has not been previously answered.  The two linked answers do not address the question I have here.  One provides an example when the timezone is a given and constant for all records in the dataframe and the timezone is specified using standard timezone format, like America/Los_Angeles, but that doesn't apply in my case where my time zone is listed as a difference in hours, and that difference is not constant across all records.</p>
  <p>I have a pandas data frame that containing two fields: hour listed in UTC, and the local time zone listed as -5:00 (for example).  I want to modify the data frame so that it creates a new field containing the local time.</p>
  <p><code>data  = [['7:00', '-5:00'], ['6:30', '-5:00'], ['8:00', '-6:00']]</code></p>
  <p><code>df = pd.DataFrame(data, columns = ['Hour', 'TimeZone'])</code></p>
  <p>I have tried converting the TimeZone into an integer and then usig</p>
  <pre><code>df['LocalTime'] = pd.to_datetime(df['Hour'])-datetime.timedelta(hours = df['TimeZone')
  </code></pre>
  <p>but that didn't work for me</p>
  <p>I also tried to convert the timezone into an integer (because in this case, I know that they will only exist as whole numbers), and then I get an error indicating I can't use a series value for the hours input variable.</p>
  <p>Can someone help me figure out what I need to do to accomplish this?</p>
  <p>Thanks,
  Brad</p>