Skip to content

Instantly share code, notes, and snippets.

@Alakhator
Created March 2, 2020 13:10
Show Gist options
  • Save Alakhator/a3def65ea87dc3b6f3c69e05e99876ce to your computer and use it in GitHub Desktop.
Save Alakhator/a3def65ea87dc3b6f3c69e05e99876ce to your computer and use it in GitHub Desktop.
mean_purchase =df.groupby('User_ID')["Purchase"].mean().rename("User_mean").reset_index()
df_1 = df.merge(mean_purchase)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment