def create_dummies(df,col_name):
col_dummies=pd.get_dummies(df[col_name],prefix=col_name)
col_dummies.drop(col_dummies.columns[0],axis=1,inplace=True)
df=pd.concat(df[col_dummies],axis=1)
df.drop(col_name,axis=1,inplace=True)
return df
data_cat=data[['Brick','Neighborhood']]
for c_feature in ['Brick','Neighborhood']:
data_cat[data_cat['c_feature']]=data_cat[data_cat['c_feature']].astype('category')
data_cat=create_dummies(data_cat,c_feature)
data_cat[data_cat['c_feature']]=data_cat[data_cat['c_feature']].astype('category')
data_cat=create_dummies(data_cat,c_feature)
我正在使用实用程序功能为两个类别var的Brick
和Neighborhood
创建假人。
我遇到c_feature
的关键错误