Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pandas pivot_table multiple aggfunc

When I create a pivot table on a dataframe I have, passing aggfunc='mean' works as expected, aggfunc='count' works as expected, however aggfunc=['mean', 'count'] results in: AttributeError: 'str' object has no attribute '__name__

This format seemed to work previously: Multiple AggFun in Pandas

How do I create a pivot table with multiple functions?

like image 857
DataSwede Avatar asked May 22 '14 18:05

DataSwede


1 Answers

I've found that this works if you simply replace square brackets with ordinary brackets i.e.

aggfunc=('count','mean')
like image 83
Toby Petty Avatar answered Sep 28 '22 04:09

Toby Petty