-4

I have a R's aggregate function:

usefulTopics = aggregate(Count ~ ID1 + Topic1 + ID2 + Topic2, data = usefulTopics, sum, na.rm = TRUE)

I want to convert this code to python and get the dataframe. How can I do so?

Sociopath
  • 13,068
  • 19
  • 47
  • 75
Rabin Poudyal
  • 717
  • 6
  • 20

1 Answers1

0

This should do the trick:

usefulTopics = usefulTopics.groupby('Count')['ID1', 'Topic1', 'ID2', 'Topic2'].agg('sum')
Joe Patten
  • 1,664
  • 1
  • 9
  • 15