I have the following dataframe
import pandas as pd
import numpy as np
df = pd.DataFrame()
df['Name'] = ['AK', 'Ram', 'Ram', 'Singh', 'Murugan', 'Kishore', 'AK']
df['Email'] = ['AK@gmail.com', 'a@djgbj.com', 'a@djgbj.com', '3454@ghhg.io', 'dgg@qw.cc', 'dgdg@dg.com', 'AK@gmail.com']
df['Cat'] = ['ab1', 'ab2', 'ab1', 'ab2', 'ab1', 'ab2', 'ab1']
df['Id'] = ['abc1', 'abc2', 'abc3', 'abc4', 'abc5', 'abc6', 'abc7']
For the following code
dfs=df.groupby(['Email', 'Cat'])['Email'].count().reset_index(name='Number')
It gives:
      Email         Cat Number
0   3454@ghhg.io    ab2 1
1   AK@gmail.com    ab1 2
2   a@djgbj.com     ab1 1
3   a@djgbj.com     ab2 1
4   dgdg@dg.com     ab2 1
5   dgg@qw.cc       ab1 1
How to group by on dfs to get the following output?
Cat Number Count
ab1 1      3
ab1 2      1
ab2 1      3
 
     
     
    