Skip to content

Instantly share code, notes, and snippets.

@ivanvoid
Created November 9, 2021 02:46
Show Gist options
  • Save ivanvoid/fbf386fd1bf9ef23877b7acaa3e2bace to your computer and use it in GitHub Desktop.
Save ivanvoid/fbf386fd1bf9ef23877b7acaa3e2bace to your computer and use it in GitHub Desktop.
turnung categorical values to numerical once
# turnung categorical values to numerical once
def name2num(name):
return [all_letters.index(l) for l in name]
def num2name(num):
return [all_letters[n] for n in num]
def category2num(c):
return all_categories.index(c)
def num2category(num):
return all_categories[num]
for i, batch in data.iterrows():
category, name = batch
data.loc[i, 'name'] = name2num(name)
data.loc[i, 'category'] = category2num(category)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment