This is perhaps more of a coding question than data science so apologies if this is not the right platform to ask this.
My question is related to the
'description' corresponds to a text/string data column with 9508 rows. The following works as expected:
In : transformer = ColumnTransformer(transformers=[('text-features', CountVectorizer(), 'description')]) In : X=transformer.fit_transform(df) In : X.shape Out: (9508, 5913)
However, the following (note the
In : transformer = ColumnTransformer(transformers=[('text-features', CountVectorizer(), ['description'])]) In : X=transformer.fit_transform(df)
does not work as expected:
In : X.shape Out: (1, 3)
Note that there is no issue parsing the list of column names for other transformers such as
OneHotEncoder(). This is making it difficult to programmatically configure transformers for dataframes containing heterogenous data type columns.
One possibility is to configure transformer for each column individually even if multiple columns require the same transformer but I was wondering if there is better way to deal with this?