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