Created
November 9, 2021 02:46
-
-
Save ivanvoid/fbf386fd1bf9ef23877b7acaa3e2bace to your computer and use it in GitHub Desktop.
turnung categorical values to numerical once
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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