0

here is the reproducible problem:

import pandas as pd

data=range(50)
df1=pd.DataFrame(data, index=pd.date_range('2013-8-1 8:00:00',freq='1S',periods=len(data))).tz_localize('Europe/Berlin')
t1=pd.date_range(df1.index[0],df1.index[-1],freq='10S')
res1=df1.groupby(df1.index).last().reindex(t1, method='ffill')
res1.index.tzinfo.zone # 'Europe/Berlin'

df2=pd.DataFrame(data, index=pd.date_range('2013-8-2 8:00:00',freq='1S',periods=len(data))).tz_localize('Europe/Berlin')
t2=pd.date_range(df2.index[0],df2.index[-1],freq='10S')
res2=df2.groupby(df2.index).last().reindex(t2, method='ffill')
res2.index.tzinfo.zone # 'Europe/Berlin'


tot=pd.DataFrame()
tot=tot.append(res1)
tot.index.tzinfo.zone #'Europe/Berlin'
tot=tot.append(res2)
tot.index.tzinfo.zone # BUG: UTC !!!!!!!!!!!!!!!!!!!!!!!!!!!!! 

# concat works instead
tot_list=[]
tot_list.append(res1)
tot_list.append(res2)
tot=pd.concat(tot_list)
tot.index.tzinfo.zone #'Europe/Berlin'

so we call tot=tot.append(res2) the second time the timezone switches to UTC altough all involved objects have Berlin timezone (tot, res1, res2).

So I suppose we can safely declare this as a bug. Any comments?

In any case concat produces a different output than subsequent append calls. This could be a test case to add...

Mannaggia
  • 4,559
  • 12
  • 34
  • 47
  • You could submit this to https://github.com/pydata/pandas/issues so that it's in the bug tracker. That said, you'll probably get better performance out of `concat` anyway. – TomAugspurger Feb 10 '14 at 17:22
  • Actually hold on. This shouldn't work since you're line `tot=tot.append(res1)` appends a `DatetimeIndex` (with tzinfo) to an `Index` (with no tzinfo). The index is empty, but that doesn't matter. `df1.append(df2).index.tzinfo.zone` gives the right answer. – TomAugspurger Feb 10 '14 at 17:29
  • but tot.index.tzinfo.zone is 'Europe/Berlin' and res2.index.tzinfo.zone is also 'Europe/Berlin', they both have a tzinfo?? – Mannaggia Feb 10 '14 at 17:33
  • What version of pandas are you using? I just tried on master and `tot.append(res1).index.tzinfo.zone` keeps the `'Europe/Berlin'` timezone. – TomAugspurger Feb 10 '14 at 17:42
  • my pd.version.version is '0.13.0-408-g464c1f9', did you check also if it still keeps this the second time, when you append res2? Because only at this moment I see the problem (see my example) – Mannaggia Feb 10 '14 at 17:55

0 Answers0