Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pandas merge with dataframes of different frequency (hourly and daily)

I'm trying to merge dataframes that are either daily or hourly. It seems on the first iteration through my loop, I can merge the first daily with hourly values. But the second time around I get this error:

raise Exception('Cannot join tz-naive with tz-aware DatetimeIndex')
Exception: Cannot join tz-naive with tz-aware DatetimeIndex

I can't really provide a good example, but I now that all the dataframes are tz-aware when they are created (e.g. I call df.tz_localize('UTC') on each after it is created.

like image 473
John Avatar asked May 30 '13 15:05

John


1 Answers

I think the easiest thing to do would be to make your frames non-timezone aware (timezone unaware?). Maybe

df_no_tz = df.copy()
df_no_tz.index.tz = None

I don't know, but it sounds like something in pandas is either creating a frame without a timezone, or removing your timezone information. Making the frames timezone agnostic may fix this (if this is what it is, implying this is a bug in pandas).

like image 200
danodonovan Avatar answered Nov 15 '22 19:11

danodonovan