Skip to content
Quantoros

Why select a text column by a scalar string, rather than a list containing that string, for CountVectorizer inside…

Classic MLLevel: IntermediateOne-dimensional text routing

Why select a text column by a scalar string, rather than a list containing that string, for CountVectorizer inside ColumnTransformer?

Hints
  • Check the dimensionality expected by the transformer.
  • One column does not always mean a one-dimensional object.

Answer

A scalar selector yields one-dimensional text input; a list yields a two-dimensional table. Text vectorizers expect an iterable of documents, not a one-column matrix of rows.

Source and licence: scikit-learn 1.7.2 — compose · BSD-3-Clause · answer: Quantoros editorial

Related questions