Skip to content

Instantly share code, notes, and snippets.

@wtberry
Created June 23, 2019 22:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wtberry/3891f6fa0dd8064351ee58529a6af412 to your computer and use it in GitHub Desktop.
Save wtberry/3891f6fa0dd8064351ee58529a6af412 to your computer and use it in GitHub Desktop.
from sklearn.preprocessing import OrdinaryEncoder
# creating mapping from unique label texts to unique integers
# note this can be re-used to encode and decode the labels after as well
encoder = OrdinaryEncoder().fit(df['code'])
# using the encoder to encode the entire dataset
y = encoder.transform(encoder)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment