df.pivot_table(values='col1', index='col2', aggfunc=[np.median, np.mean]) # index can also be list of columns # other way df.pivot_table(values='col1', index='col2', columns='col3', fill_value=0, margins=True) # margins for summary statistic
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter