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

Enable None sentinel for columns #207

Conversation

vsriram11
Copy link

@vsriram11 vsriram11 commented Apr 28, 2020

There is a None sentinel for transformers, but not columns. Having a None sentinel for the columns allows a set of transformers to act on all columns of the incoming dataframe.

None sentinel for columns is important, because sometimes we don't know the columns of the dataframe. For instance, if DataFrameMapper is embedded in a long sklearn Pipeline that may have added many columns to the original dataframe, it's hard to know exact column names in the dataframe that comes in (but we may want to apply some transfomrers to all columns).

This feature also bridges the gap to make DataFrameMapper a fully-fledged PandasFeatureUnion. - something that has been requested multiple times in Issue #62 , #64 , and #69 .

@ragrawal
Copy link
Collaborator

ragrawal commented May 8, 2021

@vsriram11 this is now (release V2.2.0) possible using callable methods. You can do something like this:

class AllColumnSelector:
        def __call__(self, X:pd.DataFrame=None):
              return list(X.columns)

mapper = DataFrameMapper([
      (AllColumnSelector(), None)
])

@ragrawal ragrawal closed this May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants