You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
group_keys : bool, default True
When calling apply, add group keys to index to identify pieces.
But it seems to work for some cases and not others:
df = pd.DataFrame({'key': [1, 1, 1, 2, 2, 2, 3, 3, 3],
'value': range(9)})
df.groupby('key', group_keys=True).apply(lambda x: x.key) # index by groups
df.groupby('key', group_keys=True).apply(pd.np.sum) # index by groups
df.groupby('key', group_keys=True).apply(lambda x: x[:].key) # index by groups
df.groupby('key', group_keys=True).apply(lambda x:x-x.mean()) # does nothing
df.groupby('key', group_keys=True).apply(lambda x:x) # does nothing
For example, the following gives the same output regardles of the group_keys value
According to the df.groupby docstring :
But it seems to work for some cases and not others:
For example, the following gives the same output regardles of the
group_keys
valuexref #22545 for related groupby confusion.
The text was updated successfully, but these errors were encountered: