Skip to content

fix: More robust str → date conversion when reading from spreadsheet #22276

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

Merged
merged 1 commit into from
Apr 15, 2025

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Apr 15, 2025

Closes #21068.

Strip any trailing zero-time components (eg: 00:00:00 or 00:00:00.000000) before applying .str.to_date(), when Date dtype is indicated.

We were doing this in some places already, but this PR ensures that we do it consistently across all supported engines, and adds some test coverage to validate.

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Apr 15, 2025
@alexander-beedie alexander-beedie changed the title fix: More robust str -> date conversion when reading from spreadsheet fix: More robust str → date conversion when reading from spreadsheet Apr 15, 2025
@alexander-beedie alexander-beedie added the A-io-spreadsheet Area: reading/writing Excel/ODS files label Apr 15, 2025
Copy link

codecov bot commented Apr 15, 2025

Codecov Report

Attention: Patch coverage is 86.95652% with 3 lines in your changes missing coverage. Please review.

Project coverage is 80.76%. Comparing base (9f8976f) to head (d02213f).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
py-polars/polars/io/spreadsheet/functions.py 86.95% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #22276      +/-   ##
==========================================
- Coverage   80.77%   80.76%   -0.02%     
==========================================
  Files        1640     1640              
  Lines      235594   235827     +233     
  Branches     2714     2720       +6     
==========================================
+ Hits       190302   190462     +160     
- Misses      44651    44722      +71     
- Partials      641      643       +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ritchie46 ritchie46 merged commit 2d578bb into pola-rs:main Apr 15, 2025
22 checks passed
@alexander-beedie alexander-beedie deleted the spreadsheet-str-to-date branch April 16, 2025 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-io-spreadsheet Area: reading/writing Excel/ODS files 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.

read_excel for pl.Date in schema_overrides generates "define a format" error
2 participants