0

I have the following dataframe:

                         BTC    ETH
 date       
 2016-11-10 01:00:00    714.02  10.55
 2016-11-10 02:00:00    715.64  10.51

How can I convert the index (which is in GMT) to CET? Or, how can I add 1 hour to the index?

Thank you!

MathMan 99
  • 665
  • 1
  • 7
  • 19
  • 2
    [pandas.Series.dt.tz_convert](https://pandas.pydata.org/pandas-docs/version/0.23/generated/pandas.Series.dt.tz_convert.html) or [pandas.tseries.offsets.DateOffset](https://pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.html) – It_is_Chris Nov 17 '21 at 15:51
  • @It_is_Chris how would you use your format? I am not sure how tz convert works – MathMan 99 Nov 17 '21 at 15:58
  • @not_speshal for some reason it is not working as expected – MathMan 99 Nov 17 '21 at 16:02
  • 1
    @MathMan99 `df.index = df.index.tz_localize('CET')` if your dates are time zone naive or `df.index = df.index.tz_convert('CET')` if they are not – It_is_Chris Nov 17 '21 at 16:05
  • @not_speshal, for some reason it put all my indexes to "1:00:00" rather than offset by 1 hour. Do you know if there is another way? – MathMan 99 Nov 17 '21 at 16:06
  • 1
    @MathMan99 - Try `df.index + pd.DateOffset(hours=1)` – not_speshal Nov 17 '21 at 16:10
  • @It_is_Chris, how do I accommodate for daylight savings? I get the error : NonExistentTimeError. I am converting GMT to CET. – MathMan 99 Nov 19 '21 at 19:37

0 Answers0