0

I generated the following dummy variables for the data to be used for a linear regression model.

dummy variables

data = df.copy() #make a copy of our cleaned dataset called data
X = data[['age', 'blood_pressure', 'specific_gravity', 'albumin', 'sugar',
       'pus_cell', 'pus_cell_clumps', 'bacteria', 'blood_glucose_random',
       'blood_urea', 'serum_creatinine', 'sodium', 'potassium', 'hemoglobin',
       'packed_cell_volume', 'white_blood_cell_count', 'red_blood_cell_count',
       'hypertension', 'diabetes_mellitus', 'coronary_artery_disease',
       'appetite', 'pedal_edema', 'anemia','classification'
       ]]
#convert all object/category columns into dummy/indicator variables.
X = pd.get_dummies(data= X, drop_first=True)
X.head()

I want the classification column dummy variable to be classification_ckd

How can I accomplish this?

ActuS98
  • 11
  • 2

1 Answers1

0

You need to use prefix like this pd.get_dummies(df, prefix=['col1', 'col2']). Read further details from this documentation Pandas-doc

PKS
  • 618
  • 1
  • 7
  • 19