Pandas throws a Future Warning when I apply a function to multiple columns of a groupby object. It suggests to use a list as index instead of tuples. How would one go about this?
>>> df = pd.DataFrame([[1,2,3],[4,5,6],[7,8,9]])
>>> df.groupby([0,1])[1,2].apply(sum)
<stdin>:1: FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be deprecated, use a list instead.
1 2
0 1
1 2 2 3
4 5 5 6
7 8 8 9
[[1, 2]]
. 2 Brackets is how you do DataFrame selection (i.e. selection with a list). I'm suprirsed [1,2] has worked all this time.[[1,2]].sum()
. No need toapply
the built-in python'ssum
function