-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat: Add dt.replace
#19708
feat: Add dt.replace
#19708
Conversation
@MarcoGorelli I could also perhaps use some help creating tests to cover the |
sure - would it work to start with
and then do |
Thanks--looks like I need to use |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19708 +/- ##
==========================================
+ Coverage 79.60% 79.63% +0.02%
==========================================
Files 1567 1568 +1
Lines 218398 218628 +230
Branches 2465 2465
==========================================
+ Hits 173866 174095 +229
- Misses 43963 43964 +1
Partials 569 569 ☔ View full report in Codecov by Sentry. |
db96828
to
75c4446
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for working on this, it'll probably be useful to people
7515383
to
581dba0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks - the microsecond / nanosecond part looks a bit off?
In [12]: df = pl.DataFrame({'a': ['2020-01-01T00:00:00.123456789']*2}).select(pl.col('a').str.to_dat
...: etime(time_unit='ns'))
In [13]: df
Out[13]:
shape: (2, 1)
┌───────────────────────────────┐
│ a │
│ --- │
│ datetime[ns] │
╞═══════════════════════════════╡
│ 2020-01-01 00:00:00.123456789 │
│ 2020-01-01 00:00:00.123456789 │
└───────────────────────────────┘
In [14]: df['a'].dt.replace(year=2021)
Out[14]:
shape: (2,)
Series: 'a' [datetime[ns]]
[
2021-01-01 00:00:00.123456
2021-01-01 00:00:00.123456
]
062066e
to
e3b8896
Compare
e3b8896
to
7bc79a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print statement
😄 no worries, thanks for updating looks like there's another merge conflict, sorry |
Figured that would happen that with that PR. Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, thanks @mcrumiller !
Leaving open a bit in case there's objections
separately to this PR, as a follow-up, py-polars/tests/unit/operations/namespaces/temporal/test_datetime.py
has become very big, I think it'd be worth splitting these dt.replace
tests into a separate test file
There's been no objections, and I think this feature would be really ergonomic (and higher-perf than some current alternatives involving |
Closes #8879.
@MarcoGorelli since this involves constructing new
Date
/Datetime
chunked arrays, I moved some of thefn datetime()
construction code that needed to be reused intoDateChunked::new_from_parts
andDatetimeChunked::new_from_parts
.Examples