pandas groupby count sort code example Example: groupby count pandas df.groupby(['col1', 'col2']).size()