Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add argument for alternative indexing of OrdinalEncoder #291

Open
wildcat47 opened this issue Feb 11, 2021 · 0 comments
Open

Add argument for alternative indexing of OrdinalEncoder #291

wildcat47 opened this issue Feb 11, 2021 · 0 comments

Comments

@wildcat47
Copy link

wildcat47 commented Feb 11, 2021

Expected Behavior

There are a variety of applications in which zero-indexing would be preferred for the OrdinalEncoder. One example is preparing features for a PyTorch model with categorical embeddings, in which case the ordinal label is used to slice dimensions of an embedding matrix. Note also that the sklearn OrdinalEncoder is zero-indexed.

One could possibly add an argument to init() that specifies the indexing (e.g., self.index_start), so that the ordinal_encoding() method can do something like:

data = pd.Series(index=index, data=range(self.index_start, len(index) + self.index_start))

Actual Behavior

The ordinal_encoding() method imposes one-indexing in this line:
data = pd.Series(index=index, data=range(1, len(index) + 1))

Specifications

  • Version: 2.2.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants