Skip to content

Instantly share code, notes, and snippets.

@hadinh1306
Last active January 20, 2020 07:02
Show Gist options
  • Select an option

  • Save hadinh1306/296030c0ec619ea68a894b2fb3380d14 to your computer and use it in GitHub Desktop.

Select an option

Save hadinh1306/296030c0ec619ea68a894b2fb3380d14 to your computer and use it in GitHub Desktop.
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