I am trying to convert UTC data to local time Mozambique. For Mozambique the local time follows GMT+2 or Africa/Maputo. However, when using .tz_localize('UTC').tz_convert(X)
where X can either be = 'GMT+2'
or = 'Africa/Maputo'
I get separate answers. As an example:
import pandas as pd
import numpy as np
np.random.seed(2019)
N = 1000
rng = pd.date_range('2019-01-01', freq='10Min', periods=N)
df = pd.DataFrame(np.random.rand(N, 3), columns=['temp','depth','acceleration'], index=rng)
print(df.tz_localize('UTC').tz_convert('Etc/GMT+2'))
print(df.tz_localize('UTC').tz_convert('Africa/Maputo'))
The code that solves my problem is: df.tz_localize('UTC').tz_convert('Africa/Maputo')
. Therefore, I wonder if I have misunderstood the tz_convert('Etc/GMT+2')
method, and why the two different solutions dont provide the same answers. tz_convert('Etc/GMT-2')
solves the trick but is not intuitive, at least to me.
Thanks in advance.