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

fix: nw.selectors.by_dtype(nw.Datetime) was excluding tz-aware for Polars #1869

Merged
merged 11 commits into from
Jan 26, 2025

Conversation

MarcoGorelli
Copy link
Member

closes #1313

What type of PR is this? (check all applicable)

  • πŸ’Ύ Refactor
  • ✨ Feature
  • πŸ› Bug Fix
  • πŸ”§ Optimization
  • πŸ“ Documentation
  • βœ… Test
  • 🐳 Other

Related issues

  • Related issue #<issue number>
  • Closes #<issue number>

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below

Comment on lines 221 to 225

native_dtypes: list[pl.DataType | type[pl.DataType]] = []
for dtype in dtypes:
native_dtype_instantiated = narwhals_to_native_dtype(dtype, self._version)
if isinstance(dtype, type) and issubclass(dtype, DType):
native_dtypes.append(native_dtype_instantiated.__class__)
else:
native_dtypes.append(native_dtype_instantiated)
return PolarsExpr(
pl.selectors.by_dtype(
[narwhals_to_native_dtype(dtype, self._version) for dtype in dtypes]
),
Copy link
Member Author

Choose a reason for hiding this comment

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

the issue was that we were translating nw.Datetime to pl.Datetime(). In other parts of the codebase, that's fine. But here, we need to preserve whether the dtype is instantiated or not, as they behave differently

Like this, we keep the translation from nw.Datetime to pl.Datetime

@MarcoGorelli MarcoGorelli marked this pull request as ready for review January 26, 2025 19:23
@MarcoGorelli MarcoGorelli merged commit 5f45151 into narwhals-dev:main Jan 26, 2025
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

selectors.by_dtype doesn't select tz-aware columns
1 participant