Last active
January 20, 2020 07:02
-
-
Save hadinh1306/296030c0ec619ea68a894b2fb3380d14 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| string_star_mask = df['Stars'].isin(['Unrated', 'NR', '1/4', '1/2', '1/3', | |
| '3.5/2.5', '4/4', '5/5', '4.5/5', | |
| '5/2.5', '5/4', '4.25/5']) | |
| df_length = len(df) | |
| print(f"Percentage of rows with `Unrated`, `NR` or mixing rates in the dataset is | |
| {np.sum(string_star_mask)*100/df_length:.2}%.") | |
| # Remove string ratings from the dataset | |
| df = df[~string_star_mask] | |
| # Transform rating column to a numeric column | |
| df['Stars'] = pd.to_numeric(df['Stars']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment