Python Forum
how to: explicitly select the grouping columns after groupby - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: how to: explicitly select the grouping columns after groupby (/thread-42074.html)



how to: explicitly select the grouping columns after groupby - sawtooth500 - May-05-2024

backtestdf_complete.groupby(['b_index', 'sample_dur']).apply(day_test)
That bit of code is throwing me:

Output:
/Volumes/Python/findparams.py:123: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning. backtestdf_complete.groupby(['b_index', 'sample_dur']).apply(day_test, include_groups=True)
So I need my grouping columns to be included in the operation. So per the warning I'm guessing I can "explicitly select the grouping columns after groupby" - but how do I do that? I cannot find an example... thank you.