OneHotEncoder.get_feature_names doesn't work with integer column names
See original GitHub issueimport pandas as pd
import numpy as np
from sklearn.preprocessing import OneHotEncoder
X = pd.DataFrame({1: np.random.randint(0, 10, size=400)})
OneHotEncoder().fit(X).get_feature_names([1])
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Issue Analytics
- State:
- Created 4 years ago
- Comments:29 (24 by maintainers)
Top Results From Across the Web
Sklearn Pipeline: Get feature names after OneHotEncode In ...
get_feature_names () method depends on the order of declaration of the steps variable at the ColumnTransformer instanciation. I could not find ...
Read more >Get the feature names output by a ColumnTransformer
Need to get the feature names output by a ColumnTransformer?Use get_feature_names (), which now works with "passthrough" columns (new in ...
Read more >Keeping pandas dataframe column names when using ...
Keeping pandas dataframe column names when using Pipeline with OneHotEncoder. In this post, I will show how to create a simple custom ...
Read more >sklearn.compose.ColumnTransformer
List of (name, transformer, columns) tuples specifying the transformer objects to be applied to subsets of the data. ... Number of jobs to...
Read more >The 6-Minute Guide to Scikit-learn's Version 1.0 Changes
Note that get_feature_names has been deprecated. get_feature_names_out doesn't work with all transformers, yet, but it works with ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
HI everybody, sorry for stepping in. I would like to point that there is another issue on OneHotEncoder (#16552) and @glemaitre and I we were waiting for a comment about the possibility of changing the
drop_idx_
array from an array of integer to an array of objects (https://github.com/scikit-learn/scikit-learn/issues/16552#issuecomment-592187612). This choice will probably change the way this issue should be solved too.Introduced in https://github.com/scikit-learn/scikit-learn/pull/16560 lol I have not realized it would also affect core-devs, we would probably want to open issues as “Other” reason and manually assign tags. It’s was intended for unconfirmed users reports, there may be a better way to do it.