Skip to content

Instantly share code, notes, and snippets.

@grahamharrison68
Created November 24, 2021 07:42
Show Gist options
  • Save grahamharrison68/58629e3c33a8472a798606453e6db744 to your computer and use it in GitHub Desktop.
Save grahamharrison68/58629e3c33a8472a798606453e6db744 to your computer and use it in GitHub Desktop.
df_drug = pd.read_csv("drug200.csv")
label_encoder = LabelEncoder()
categorical_features = [feature for feature in df_drug.columns if df_drug[feature].dtypes == 'O']
for feature in categorical_features:
print(feature, list(df_drug[feature].unique()), list(label_encoder.fit_transform(df_drug[feature].unique())), "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment