Skip to content

Resample with period='AS'/'A' does not work on localized indexes for multiple methods in "how" #6397

Closed
@jphme

Description

@jphme

I encountered a similar issue to (closed) #3592 .

When trying to resample a dataframe with a localized Datetime Index using the how method:

rng = pd.date_range('1/1/2011', periods=20000, freq='H')
rng = rng.tz_localize('EST')
ts = pd.DataFrame(index=rng)
ts['first']=np.random.randn(len(rng))
ts['second']=np.cumsum(np.random.randn(len(rng)))
ts2=ts.resample('A', how={'first':np.sum, 'second':np.mean})

*File "tslib.pyx", line 465, in pandas.tslib._Timestamp.__richcmp__ (pandas\tslib.c:9313)
*TypeError: can't compare offset-naive and offset-aware datetimes

For other (,lower) frequencies like "M" the same code works fine and if I just use

how=np.mean

or just use 1 column in the dict

how={'first':np.mean}

it works too.

python 2.7.5
pandas 0.13.1

EDIT: Changed to include full example

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions