Create dummy variable

https://app.dataquest.io/m/185/getting-started-with-kaggle/4/preparing-our-data-for-machine-learning

def create_dummies(df,column_name):
dummies = pd.get_dummies(df[column_name],prefix=column_name)
df = pd.concat([df,dummies],axis=1)
return df

My Code:
def create_dummies(df,column_name):
    dummies = pd.get_dummies(df[column_name],prefix=column_name)
    dummies = dummies.iloc[:,:-1]
    df = pd.concat([df,dummies],axis=1)
    return df 

Why we didn’t remove one of the dummy variable although suppose we remove one of them & compare the coefficient for other variable with the base which is what we removed

1 Like