question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OneHotEncoder.get_feature_names doesn't work with integer column names

See original GitHub issue
import 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:open
  • Created 4 years ago
  • Comments:29 (24 by maintainers)

github_iconTop GitHub Comments

1reaction
cmarmocommented, Feb 29, 2020

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.

1reaction
rthcommented, Feb 28, 2020

What’s the etiquette on bug: triage. Should I move the label to bug or should I wait for someone else to do that?

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found