Skip to content

Instantly share code, notes, and snippets.

@Olshansk
Last active May 25, 2020 23:16
Show Gist options
  • Save Olshansk/b7d1c569f5a436b453438de88663cae5 to your computer and use it in GitHub Desktop.
Save Olshansk/b7d1c569f5a436b453438de88663cae5 to your computer and use it in GitHub Desktop.
Transition Matricies - Bucketize Data
NUM_BINS = 10
bins = np.linspace(0, 100, NUM_BINS + 1)
# Note: we set include_lowest to true to make sure that we include zeroes
bucket_GT = pd.cut(grades_GT, bins=bins, include_lowest=True, right=True)
bucket_P = pd.cut(grades_P, bins=bins, include_lowest=True, right=True)
# Output of the cut function
pd.DataFrame({'grades': grades_GT, 'bucket': bucket_GT}).head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment