0

I have no clue why this is hapening. These are the facts; 1 - I have a real life Dataframe that is really, really messy.

A         B                c
John      1/10/2018        100,00
Mark      NA               50,00
          2/09/2018        30,00
Susan     8/10/2018        NA
Mark      8/10/2018        10,00
John      1/10/2018        20,00
NA        NA               40,00

Consider that columns B is already set to Datetime and column C is already set to a float.

So, the sum of this dataframe is 250,00

df['c'].sum()

When I do a groupby, I get another result which is lower

df2 = df.groupby('c').sum()

I get a value that is lower. What I want is to have a df like this:

B                c
2/09/2018        30,00
1/10/2018        120,00
8/10/2018        10,00
NA               90,00

Tks for the help!!!

user1922364
  • 513
  • 2
  • 8
  • 19
  • 1
    Are you sure `df2 = df.groupby('c').sum()` ? – jezrael Feb 26 '19 at 13:57
  • sorry, df2 = df.groupby['c'].reset_index() thes df2['c'].sum() – user1922364 Feb 27 '19 at 15:41
  • Do you think `df.groupby('b')['c'].sum()` vs `df['c'].sum()`? Because if use `df.groupby('c').sum()` it grouping by column `c`, so output have to be different like grouping by column `b` with aggregate `c`. – jezrael Feb 27 '19 at 18:03

0 Answers0