Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pivot_table value aggfunct

table = pd.pivot_table(df, values=['D', 'E'], index=['A', 'C'],
...                     aggfunc={'D': np.mean,
...                              'E': [min, max, np.mean]})
>>> table
                D    E
            mean  max      mean  min
A   C
bar large  5.500000  9.0  7.500000  6.0
    small  5.500000  9.0  8.500000  8.0
foo large  2.000000  5.0  4.500000  4.0
    small  2.333333  6.0  4.333333  2.0
Comment

PREVIOUS NEXT
Code Example
Python :: how to multiply two lists in python 
Python :: mp.solutions.findhands not in python 3.8 
Python :: p and c in python 
Python :: candle stick with volume plotly 
Python :: numpy np sign change in df pandas zero crossing 
Python :: jupyter notebook print string with variables 
Python :: onetomany field 
Python :: how to restore windows security 
Python :: exit from python manage py createsuperuser 
Python :: installing django on windows 
Python :: hewwo world 
Python :: python open file partially 
Python :: pafy python documentation 
Python :: error 302 heroku django 
Python :: python as-lookup 
Python :: request.query_dict hubspot 
Python :: next function with inherited list python 
Python :: nested dict 
Python :: how to open an application in python 
Python :: combine two dataframes of same length 
Python :: pdf to jpg 
Python :: format python decimal 
Python :: sort 2d list python 
Python :: for i in range python 
Python :: flask documentation 
Python :: if statements python 
Python :: python3 create list from string 
Python :: phone numbers 
Python :: slider python 
Python :: python code checker 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =