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?
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?
This should do the trick:
usefulTopics = usefulTopics.groupby('Count')['ID1', 'Topic1', 'ID2', 'Topic2'].agg('sum')