How to convert column that has text element to column of numerics before modelling

Viewed 13

I am working on a dataset that has
columns with text in it
How can I change Elements and Area with numbers before modelling

1 Answers

If need factorize for strings columns use:

cols = df.select_dtypes(object).columns
df[cols] = df[cols].apply(lambda x: pd.factorize(x)[0])
Related