Я написал это, и я получаю
X.select_dtypes(include='object').tail(20)
categorical_columns = [c for c in X.columns if X[c].dtype.name == 'object']
for c in categorical_columns:
X[c] = np.where(X[c] == ' ?', X[c].mode(), data[c])
X.select_dtypes(include='object').tail(20)
X = pd.concat([X, pd.get_dummies(X.select_dtypes(include='object'))], axis=1)
X = X.drop(['region', 'sales_channel','order_priority', 'country',], axis=1)
это дает:
ValueError Traceback (most recent call last)
<ipython-input-92-94055b8161bc> in <module>
3
4 for c in categorical_columns:
----> 5 X[c] = np.where(X[c] == ' ?', X[c].mode(), data[c])
6 X.select_dtypes(include='object').tail(20)
7 X = pd.concat([X, pd.get_dummies(X.select_dtypes(include='object'))], axis=1)
<__array_function__ internals> in where(*args, **kwargs)
ValueError: operands could not be broadcast together with shapes (100,) (2,) (100,)
В чем может быть проблема? Не понимаю, правда.