PageId VolumePred ConversionPred OSBrowser
955761 37200.0 27625.0 (11, 16)
955764 30157.0 21155.0 (11, 16)
955764 25258.0 17836.0 (11, 16)
1184903 35492.0 17768.0 (11, 16)
955764 24683.0 16965.0 (11, 16)
955764 8.0 0.0 (32, 16)
955761 4.0 0.0 (33, 16)
955761 4.0 0.0 (33, 16)
I try to sum of VolumePred and ConversionPred by PageID and OSBrowser.
So here for example , the needed result should be :
PageId VolumePred ConversionPred OSBrowser
955761 37200.0 27625.0 (11, 16)
955764 55415.0 38991.0 (11, 16)
1184903 35492.0 17768.0 (11, 16)
955764 24683.0 16965.0 (11, 16)
955764 8.0 0.0 (32, 16)
955761 8.0 0.0 (33, 16)
I tryied with this code :
subdata.groupby(['PageId', 'OSBrowser'])['ConversionPred', 'VolumePred'].agg('sum')
but i get this warning :
/tmp/ipykernel_16715/1460716585.py:1: FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be deprecated, use a list instead.
subdata.groupby(['PageId', 'OSBrowser'])['ConversionPred', 'VolumePred'].agg('sum')
Any idea please? thanks
CodePudding user response:
You're really close; you just need to add an extra set of square brackets:
subdata.groupby(['PageId', 'OSBrowser'])[['ConversionPred', 'VolumePred']].agg('sum')