Skip to content

Commit

Permalink
FutureWarning from groupby.
Browse files Browse the repository at this point in the history
Warning about elementwise comparison failing when we indexed
a dataframe with boolean dataframe
  • Loading branch information
TomAugspurger committed Sep 18, 2018
1 parent 79f7762 commit 1168273
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions doc/source/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,11 @@ Unlike agg, apply's callable is passed a sub-DataFrame which gives you access to
.. ipython:: python
df = pd.DataFrame({'A' : [1, 1, 2, 2], 'B' : [1, -1, 1, 2]})
gb = df.groupby('A')
def replace(g):
mask = g < 0
g.loc[mask] = g[~mask].mean()
return g
mask = g < 0
return g.where(mask, g[~mask].mean())
gb.transform(replace)
Expand Down

0 comments on commit 1168273

Please sign in to comment.