Skip to content

Instantly share code, notes, and snippets.

@RenSys
Last active February 17, 2017 08:31
Show Gist options
  • Save RenSys/ecee5f3845ea7aa64dd5e0c5f0003c07 to your computer and use it in GitHub Desktop.
Save RenSys/ecee5f3845ea7aa64dd5e0c5f0003c07 to your computer and use it in GitHub Desktop.
Pandas - Convert Timezones
import pandas as pd
df = pd.DataFrame(data = [1,2,3,4,5], index = pd.date_range("7:00", "9:00", freq="30min", tz = 'UTC'))
# convert UTC Timezone to Australia Perth
df.index = df.index.tz_convert('Australia/Perth')
# Remove TZ information from the datetime stamp, this is useful when exporting to Excel
df.index = df.index.tz_localize(None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment