0

I have a dataframe that looks like this:

  Cell1    Cell2    Cell3     
    A          B       B      
    A          B       B       
    B          B       A     
    C          B       A    

I am trying to get the following output:

  Cell1    Cell2    Cell3     sum
    A          B       B       2 
    B          B       A       1
    C          B       A       1

I tried the aggregate function, but can't find the solution for this.

3
  • 2
    Use df = df.groupby(['Cell1', 'Cell2', 'Cell3' ]).size().reset_index(name='sum') Commented Feb 4, 2021 at 9:13
  • Check second answer in dupe. Commented Feb 4, 2021 at 9:13
  • Added another dupe link. Commented Feb 4, 2021 at 9:14

0