To proceed with the recipe, let's import pandas and then create a toy dataframe with two variables, each one containing a date and time in different time zones:
- Import pandas:
import pandas as pd
- Let's create a toy dataframe with one variable with values in different time zones:
df = pd.DataFrame()df['time1'] = pd.concat([ pd.Series( pd.date_range( start='2015-06-10 09:00', freq='H', periods=3, tz='Europe/Berlin')), pd.Series( pd.date_range( start='2015-09-10 09:00', freq='H', periods=3, tz='US/Central')) ], axis=0)
- Now, let's add another datetime variable to the dataframe, which also contains values in different time zones, and then display the resulting dataframe:
df['time2'] = pd.concat([ pd.Series( pd.date_range( ...