1

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.

Salmonstrikes
  • 737
  • 1
  • 6
  • 25
  • See the quoted section in the accepted answer (from David Peden) here: https://stackoverflow.com/questions/7303580/understanding-the-etc-gmt-time-zone – Salmonstrikes Aug 31 '21 at 09:18

1 Answers1

0

The time zone conversion using etcetera works in reverse, and perhaps it should be deprecated altogether, considering the following observation on its documentation:

These entries are mostly present for historical reasons, so that people in areas not otherwise covered by the tz files could "zic -l" to a time zone that was right for their area. These days, the tz files cover almost all the inhabited world, so there's little need now for the entries that are not on UTC.

Your workaround is correct and the best explanation why can be found here. Maybe stick with the tz_convert('Africa/Maputo').