Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Combining groupby, rolling, and mean in Pandas not possible?
Post Body

Is combining these 3 methods not possible?

I have a dataframe of different people and want to create a column that is a rolling average of just that person's last X data points. I keep getting various errors and haven't been able to find a stackoverflow or youtube video explaining how to do this/if its possible.

I've gotten errors ranging from you can't have a non-unique multi-index, to columns must be the same length as key, but am not sure why I'm getting those errors.

According to a stackoverflow post this should work:

df_all['3d_MA'] = df_all.groupby('Player Name')['Distance (km)'].rolling(3).mean().reset_index(drop=True)

But it gives me a column with the wrong numbers, plus the first 2 values for each person are not NaN which they should be since there isnt enough data points.

Author
Account Strength
90%
Account Age
6 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,745
Link Karma
940
Comment Karma
805
Profile updated: 1 week ago
Posts updated: 8 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago