I have been trying to create a dummies
of the categorical variable "SEX"
in my dataset. I want to change the names of generated dummy
columns . But I could see there is an option of changing only the prefix of column name but couldn't find any way to change the entire name. Can anyone help me out?
My code for the above output is:
print(df['SEX'].value_counts())
dummy_variable=pd.get_dummies(df['SEX']).rename(columns=lambda x:'SEX_' +str(x))
print(dummy_variable)
I desired to have the output dummy column names as SEX_MALE
and SEX_FEMALE
.
Thanks in advance.