Is there any advantage to asking questions in a language that is not your native and in which you lack proficiency?
If you had written in your native language, it would have been easier to receive a response.
Despite this, I am still writing back.
import pandas as pd
data = {
"userId": [1, 2, 3, 1, 2],
"clicks": [50, 40, 45, 12, 1]
}
totalClicks = pd.DataFrame(data)
#load data into a DataFrame object:
df = pd.DataFrame(data)
print(df)
print (df.groupby('userId')['clicks'].sum().reset_index())
Let's take a scenario where we want to add the clicks of users.
The application's output is as follows.
userId clicks
0 1 50
1 2 40
2 3 45
3 1 12
4 2 1
userId clicks
0 1 62
1 2 41
2 3 45