один горячий питон питона
from sklearn.preprocessing import OneHotEncoder
encoder = OneHotEncoder()
# apply on df
color_1hot = encoder.fit_transform(df['ocean_proximity'].values.reshape(-1,1))
color_1hot_df = pd.DataFrame(color_1hot.toarray())
df = pd.concat([df.drop('ocean_proximity', axis=1), color_1hot_df], axis=1)
# can allso use the pandas dummies
df = pd.get_dummies(df, columns=['ocean_proximity'])
# apply on np.array
X[:, 2] = le.fit_transform(X[:, 2])
Adventurous Addax