from sklearn.preprocessing import OneHotEncoder
column_to_encode = ['Sex','Fasting_Blood_Sugar','Exercise_Angina']
# Create a nominal encoder object
encoder = OneHotEncoder(drop="first")
# Fit and transform the specified column using the encoder
encoded_column = encoder.fit_transform(df[column_to_encode])
# Convert the encoded column to a DataFrame
encoded_df = pd.DataFrame(encoded_column.toarray(), columns=encoder.get_feature_names_out(column_to_encode))
# Concatenate the encoded DataFrame with the original DataFrame
df = pd.concat([df, encoded_df], axis=1)
# Drop the original column that was encoded
df.drop(column_to_encode, axis=1, inplace=True)
我正在尝试这段代码。并且删除了数据集中的三个值。请帮助我理解这个