pandas_groupby
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
pandas_groupby [2021/07/06 23:06] – [preserve the highest odd value in each group] admin | pandas_groupby [2024/03/26 22:17] – [extract groupby object by key] raju | ||
---|---|---|---|
Line 77: | Line 77: | ||
==== preserve the highest odd value in each group ==== | ==== preserve the highest odd value in each group ==== | ||
+ | tags | pandas groupby transform maximum odd number, maxodd | ||
+ | |||
Given | Given | ||
< | < | ||
Line 173: | Line 175: | ||
In [5]: | In [5]: | ||
- | df.groupby([' | + | idx = df.groupby([' |
+ | idx | ||
Out[5]: | Out[5]: | ||
0 False | 0 False | ||
Line 234: | Line 237: | ||
==== extract groupby object by key ==== | ==== extract groupby object by key ==== | ||
+ | tags | pandas groupby filter a group | ||
+ | |||
* groups.get_group(key_value) if grouping on a single column | * groups.get_group(key_value) if grouping on a single column | ||
* groups.get_group(key_value_tuple) if grouping on multiple columns. | * groups.get_group(key_value_tuple) if grouping on multiple columns. | ||
Line 314: | Line 319: | ||
5 bar 0 6 | 5 bar 0 6 | ||
</ | </ | ||
+ | |||
+ | ==== groupby slicing ==== | ||
+ | |||
==== apply a function on each group ==== | ==== apply a function on each group ==== | ||
Line 360: | Line 368: | ||
tags | reset_index remove level_1 column, apply function to multiple columns and rename result, groupby apply name the result, groupby apply remove level_1 | tags | reset_index remove level_1 column, apply function to multiple columns and rename result, groupby apply name the result, groupby apply remove level_1 | ||
- | |||
pandas_groupby.txt · Last modified: 2024/05/07 20:47 by raju