Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ColumnTransformer breaks where X is a list #12096

Closed
@jnothman

Description

@jnothman
>>> from sklearn.preprocessing import StandardScaler
>>> from sklearn.compose import ColumnTransformer
>>> ColumnTransformer([('foobar', StandardScaler(), [0, 1, 2])]).fit([[1, 2, 3]])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/joel/repos/scikit-learn/sklearn/compose/_column_transformer.py", line 398, in fit
    self.fit_transform(X, y=y)
  File "/Users/joel/repos/scikit-learn/sklearn/compose/_column_transformer.py", line 422, in fit_transform
    self._validate_remainder(X)
  File "/Users/joel/repos/scikit-learn/sklearn/compose/_column_transformer.py", line 275, in _validate_remainder
    n_columns = X.shape[1]
AttributeError: 'list' object has no attribute 'shape'

The passed list should be interpreted as an array for the sake of extracting columns. Instead an error is raised.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugEasyWell-defined and straightforward way to resolvehelp wanted

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions