I have a csv file with a timestamp given in CAT (Central African Time). When I read it in as a pandas dataframe using:
df = pd.read_csv(path, parse_dates=["timestamp"], dayfirst=True)
I get an error:
C:\Users..\lib\site-packages\dateutil\parser_parser.py:1218: UnknownTimezoneWarning: tzname CAT identified but not understood. Pass
tzinfos
argument in order to correctly return a timezone-aware datetime. In a future version, this will raise an exception. category=UnknownTimezoneWarning)
which seems to indicate I need to pass a parameter tzinfos, but as far as I could see its not listed as an option for read_csv in the Pandas documentation. I tried both of:
df = pd.read_csv(path, parse_dates=["timestamp"], dayfirst=True, tzinfos={"CAT": "Etc/GMT+2"})
df = pd.read_csv(path, parse_dates=["timestamp"], dayfirst=True, tzinfos= "Etc/GMT+2")
but I keep getting an error:
TypeError: read_csv() got an unexpected keyword argument 'tzinfos'
Now at the moment its just a warning and it still reads it in as timezoneless data points to which I can just add the correct timezone info with: df.timestamp.dt.tz_localize("Etc/GMT+2")
, however the fact that the warning says "In a future version, this will raise an exception" makes me think my code will break in the future so I would prefer to fix it now.
I tried googling for a solution but all the results seem to do with general datetime conversions, not reading in a csv (I couldn't figure out how the results translate).