There are 16 categorical variables in my data set.I would like to apply a 0-1 conversion to some of them one-hot.
one hot code : df_one_hot =pd.get_dummies(df,columns = ["guardian"],prefix = ["guardian"]) df_one_hot.head()
0-1 code : df["new_day"] =np.where(df["day"].str.contains("Sun"),1,0)
because I have more than one application, I want all the conversions I do to be permanent.I applied one hot to the first data.when I applied it to the second data, I found that what I applied above was not permanent.how can I make permanent operations for both conversions? inplace=True, this function no
import pandas as pd
df = pd.read_csv("../data/student-mat.csv", sep=';')
df
.
.
.
df_one_hot =pd.get_dummies(df,columns = ["reason"],prefix = ["reason"])
df_one_hot.head()
#I am doing the first conversion. But when I do it again for the second data,
#the first conversion is not permanent.
df_one_hot =pd.get_dummies(df,columns = ["guardian"],prefix = ["guardian"])
df_one_hot.head()