Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ph-ll-pp
Copy link
Contributor

Reference Issues/PRs

Fixes #32155

What does this implement/fix?

ColumnTransformer.fit_transform failed on polars.DataFrames, if some transformers, but not all, returned a sparse matrix/array. In this case, the function tried to access a .size attribute, which is not implemented for polars.DataFrame. The bug was fixed by instead resorting to the .shape attribute which is universally implemented across numpy/pandas/polars. Tests in test_column_transformer_sparse_stacking were updated to not only test stacking of sparse matrix outputs from numpy inputs, but also from polars and pandas inputs.

Any other comments?

I also improved the docstring of the internal _convert_container helper function to indicate constructor_name="pandas" is a valid input.

@github-actions
Copy link

github-actions bot commented Sep 15, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 87b1ae9. Link to the linter CI: here

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a changelog entry based on our guidelines: https://github.com/scikit-learn/scikit-learn/blob/main/doc/whats_new/upcoming_changes/README.md

Otherwise LGTM.

@ph-ll-pp
Copy link
Contributor Author

Thanks @adrinjalali, I added the changelog entry!

@adrinjalali adrinjalali added Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one! labels Oct 6, 2025
Copy link
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @ph-ll-pp. I just pushed a commit with a few nitpicks. LGTM

@jeremiedbb jeremiedbb enabled auto-merge (squash) October 7, 2025 12:01
@ph-ll-pp
Copy link
Contributor Author

ph-ll-pp commented Oct 7, 2025

@jeremiedbb Thanks for the nitpicks, much appreciated!

@jeremiedbb jeremiedbb merged commit b2df9ed into scikit-learn:main Oct 7, 2025
36 checks passed
Tunahanyrd pushed a commit to Tunahanyrd/scikit-learn that referenced this pull request Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:compose module:utils Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ColumnTransformer.fit() fails on polars.DataFrame: AttributeError: 'DataFrame' object has no attribute 'size'

3 participants