Skip to content

Instantly share code, notes, and snippets.

@hadinh1306
Created January 20, 2020 07:12
Show Gist options
  • Select an option

  • Save hadinh1306/64efecb1d5dd321ae19055edef4f5faf to your computer and use it in GitHub Desktop.

Select an option

Save hadinh1306/64efecb1d5dd321ae19055edef4f5faf to your computer and use it in GitHub Desktop.
rating_bins = [0, 1, 2, 3, 4, 5]
rating_bin_labels = ['0-1', '1-2', '2-3', '3-4', '4-5']
df['RatingGroups'] = pd.cut(df['Stars'], rating_bins, include_lowest=True, right=True, labels=rating_bin_labels)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment