We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Third example here: http://pandas-docs.github.io/pandas-docs-travis/cookbook.html#grouping
Test code:
df = pd.DataFrame({'animal': 'cat dog cat fish dog cat cat'.split(), 'size': list('SSMMMLL'), 'weight': [8, 10, 11, 1, 20, 12, 12], 'adult' : [False] * 5 + [True] * 2}) gb = df.groupby(['animal']) def GrowUp(x): avg_weight = sum(x[x.size == 'S'].weight * 1.5) avg_weight += sum(x[x.size == 'M'].weight * 1.25) avg_weight += sum(x[x.size == 'L'].weight) avg_weight = avg_weight / len(x) return pd.Series(['L',avg_weight,True], index=['size', 'weight', 'adult']) expected_df = gb.apply(GrowUp)
On master this gives:
In [1]: pd.__version__ Out[1]: '0.15.1-112-g2e59e42' In [5]: expected_df = gb.apply(GrowUp) ... KeyError: False
The text was updated successfully, but these errors were encountered:
Joris, I have a fix for this, though messed up my commit history. What should I do for a clean PR?
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Third example here: http://pandas-docs.github.io/pandas-docs-travis/cookbook.html#grouping
Test code:
On master this gives:
The text was updated successfully, but these errors were encountered: