Skip to content

"Improve documentation on FeatureUnion behavior with polars DataFrame output causing duplicate column names" #32121

Closed

Description

@rashmitha-j

Describe the issue linked to the documentation

The current documentation for FeatureUnion describes its behavior with pandas DataFrames but does not mention how it behaves when used with polars DataFrames. Specifically, FeatureUnion concatenates outputs of its transformers before the set_output wrapper renames columns based on get_feature_names_out. This works fine with pandas but causes issues with polars since polars does not allow creating a DataFrame with duplicate column names. This leads to errors when using FeatureUnion with polars outputs.

Suggest a potential alternative/fix

The documentation should mention the behavior difference when using FeatureUnion with polars DataFrames, specifically that concatenation occurs before column renaming. This can cause duplicate column names errors in polars.

It would be helpful to add a warning or note about this limitation, and suggest possible workarounds, such as manually renaming columns or converting to pandas DataFrame before using FeatureUnion.

Including a minimal example demonstrating the issue and how to avoid it would further improve clarity for users.

Activity

  1. Swathi-Shettigar-26 commented on Sep 7, 2025

    @Swathi-Shettigar-26
  2. Ravichandranayakar commented on Sep 7, 2025

    @Ravichandranayakar
    Contributor

    "Hi, I would like to work on this issue.

    I've read through the description, and my understanding is that I need to add a warning note to the FeatureUnion documentation regarding its behavior with Polars DataFrames causing duplicate column names.

    My plan is to locate the docstring for FeatureUnion and add the warning, along with a minimal code example to demonstrate the issue and a potential workaround, as suggested.

    Could you please assign this to me?" 🙌❤️

  3. AtharvaAiren commented on Sep 7, 2025

    @AtharvaAiren

    /take

  4. Ravichandranayakar commented on Sep 7, 2025

    @Ravichandranayakar
    Contributor

    Thanks after completing I will update

  5. rashmitha-j commented on Sep 7, 2025

    @rashmitha-j
    Author
  6. adrinjalali commented on Sep 8, 2025

    @adrinjalali
    Member

    The verbose_feature_names_out already has the necessary information .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationNeeds Triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions