I want to create a function that converts categorical variables to numerical variables. After then, I want to add one more thing, when I typed the dataframe in the function at the beginning, it has to replaces unique names with numeric values. But I have an issue while I am trying. I tried something like that:
def x(data):
for col in data:
if col.dtypes() == object:
col.replace(list(df[col].unique()),
list(np.arange(data[col].nunique()),
inplace = True)
Where am I wrong?
Thanks in advance for your opinions.