-
-
Save amankharwal/043aef13c894c5ed9ffda43565171f9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = ['count','mean'] | |
df_movie_summary = df.groupby('Movie_Id')['Rating'].agg(f) | |
df_movie_summary.index = df_movie_summary.index.map(int) | |
movie_benchmark = round(df_movie_summary['count'].quantile(0.7),0) | |
drop_movie_list = df_movie_summary[df_movie_summary['count'] < movie_benchmark].index | |
print('Movie minimum times of review: {}'.format(movie_benchmark)) | |
df_cust_summary = df.groupby('Cust_Id')['Rating'].agg(f) | |
df_cust_summary.index = df_cust_summary.index.map(int) | |
cust_benchmark = round(df_cust_summary['count'].quantile(0.7),0) | |
drop_cust_list = df_cust_summary[df_cust_summary['count'] < cust_benchmark].index | |
print('Original Shape: {}'.format(df.shape)) | |
df = df[~df['Movie_Id'].isin(drop_movie_list)] | |
df = df[~df['Cust_Id'].isin(drop_cust_list)] | |
print('After Trim Shape: {}'.format(df.shape)) | |
print('-Data Examples-') | |
print(df.iloc[::5000000, :]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment