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