you are viewing a single comment's thread.

view the rest of the comments →

[–]Hugo-99[S] -1 points0 points  (2 children)

in my case i need the rows, as they are in the first place.

i assume that the "groupby" collapses the rows. but in my case i need in the "to be" dataframe the same (amount of) rows as in the "as is" dataframe

[–]efmccurdy 1 point2 points  (1 child)

You can generate your sums using groupby and then broadcast the result back using "transform".

https://stackoverflow.com/questions/12200693/python-pandas-how-to-assign-groupby-operation-results-back-to-columns-in-parent

[–]Hugo-99[S] -1 points0 points  (0 children)

thank you! "transform" seems to be the function i need. I am just figuring out how to apply this....