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: Method dt.offset_by was discarding month and year info if day was included in offset for timezone-aware columns #21291

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

MarcoGorelli
Copy link
Collaborator

@MarcoGorelli MarcoGorelli commented Feb 16, 2025

closes #21283

Previously, the logic was:

  • let mut new_t = t
  • then, when adding years / months, increment new_t
  • then, when adding days, increment new_t

The issue was that for the last step, it was starting the calculation from t rather than from new_t, which is why the linked issue reports that if 'd' is included, then years and months get discarded

I don't think new_t is necessary at all - t can just get incremented at each step, so like this there's no risk of accidentally incrementing the wrong variable

…as included in offset for timezone-aware columns
@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Feb 16, 2025
@MarcoGorelli MarcoGorelli marked this pull request as ready for review February 16, 2025 19:23
@MarcoGorelli MarcoGorelli changed the title fix: Method dt.offset_by was discaring month and year info if day was included in offset for timezone-aware columns fix: Method dt.offset_by was discarding month and year info if day was included in offset for timezone-aware columns Feb 16, 2025
Copy link

codecov bot commented Feb 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.89%. Comparing base (5e51218) to head (9b4b5ed).
Report is 16 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21291      +/-   ##
==========================================
+ Coverage   79.82%   79.89%   +0.07%     
==========================================
  Files        1596     1596              
  Lines      228565   228562       -3     
  Branches     2608     2608              
==========================================
+ Hits       182462   182620     +158     
+ Misses      45507    45346     -161     
  Partials      596      596              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ritchie46 ritchie46 merged commit 43369fb into pola-rs:main Feb 19, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

offset_by ignores y,mo,q when d is specified and timezone is different* from UTC
2 participants