Skip to content

Conversation

@Komnomnomnom
Copy link
Contributor

Using master code, when re-sampling to a frequency that would result in a single group the use of custom aggregation functions do not work as expected. The included changes fix this, and should fix #3849 too.

In [17]: import pandas as pd

In [18]: import numpy as np

In [19]: mysum = lambda x: x.sum()

In [20]: rng = pd.date_range('2000-1-1', '2000-1-10', freq='D')

In [21]: ts = pd.Series(np.random.randn(len(rng)), index=rng)

In [22]: ts.resample('M', how='sum')
Out[22]: 
2000-01-31    0.985236
Freq: M, dtype: float64

In [23]: ts.resample('M', how=mysum)
Out[23]: 
2000-01-31    0
Freq: M, dtype: float64

@jreback
Copy link
Contributor

jreback commented Aug 23, 2013

@jtratner take a look?

@jreback
Copy link
Contributor

jreback commented Sep 24, 2013

@Komnomnomnom can you add a release notes.....?

and add in tests for #3849
much appreciated

@Komnomnomnom
Copy link
Contributor Author

Done and done (I presume you meant #3849 ... ?)

@jreback
Copy link
Contributor

jreback commented Sep 25, 2013

yep..that's what I meant!

jreback added a commit that referenced this pull request Sep 25, 2013
FIX: resample to single group with custom function
@jreback jreback merged commit 86f81b4 into pandas-dev:master Sep 25, 2013
@Komnomnomnom Komnomnomnom deleted the resample-sing-grp-bug branch September 25, 2013 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: resample in single group case not using how passed function

2 participants