-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
ENH: support NaT values into datetime series for interpolation (#11701) #21851
Conversation
Glad this is getting fixed, good work. Want to handle the time delta case while you’re at it? |
@jbrockmendel - Are you referring to #19199 ? |
#19199 is also about datetime64. I'm not sure if there is a separate issue for |
Okay. I will take a look at both #19199 and timedelta64[ns] |
pandas/tests/series/test_missing.py
Outdated
@@ -1317,3 +1317,23 @@ def test_series_interpolate_intraday(self): | |||
result = ts.reindex(new_index).interpolate(method='time') | |||
|
|||
tm.assert_numpy_array_equal(result.values, exp.values) | |||
|
|||
def test_series_interpolate_nat(self): |
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.
use tz_native_fixture and paramerize
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.
Fixed in latest commit.
pandas/tests/series/test_missing.py
Outdated
result = result.interpolate() | ||
tm.assert_series_equal(result, expected) | ||
|
||
def test_series_interpolate_nat_inplace(self): |
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.
same
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.
you can parameterize over inplace as well
@@ -6112,6 +6112,14 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False, | |||
raise NotImplementedError("Interpolation with NaNs in the index " | |||
"has not been implemented. Try filling " | |||
"those NaNs before interpolating.") | |||
is_datetime = False |
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.
this needs to be pushed down to the block in pandas/core/internals
, should go with def _interpolate
I think
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.
I have to explore more about it. Will do that in a day or two.
@atulaggarwal needs rebase. We can try to push this through as is, or aim for the cleaner long-term solution of implementing interpolate on DatetimeArray and TimedeltaArray. |
# Conflicts: # doc/source/whatsnew/v0.24.0.txt
Codecov Report
@@ Coverage Diff @@
## master #21851 +/- ##
==========================================
- Coverage 92.05% 91.91% -0.14%
==========================================
Files 169 164 -5
Lines 50733 49998 -735
==========================================
- Hits 46702 45958 -744
- Misses 4031 4040 +9
Continue to review full report at Codecov.
|
@jbrockmendel - Updated PR with latest master. I would suggest merging it as is. I will work on working on other items too (but lets not block on them) as current PR solves one of the problem. What do you suggest? |
@@ -182,6 +182,8 @@ Other Enhancements | |||
- :func:`to_timedelta` now supports iso-formated timedelta strings (:issue:`21877`) | |||
- :class:`Series` and :class:`DataFrame` now support :class:`Iterable` in constructor (:issue:`2193`) | |||
- :class:`DatetimeIndex` gained :attr:`DatetimeIndex.timetz` attribute. Returns local time with timezone information. (:issue:`21358`) | |||
- Implement interpolating ``NaT`` values in ``datetime`` series (:issue:`11701`) |
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.
The wording here is awkward. It doesn't need to be a complete sentence per se, but take a look at the other entries for examples.
As jreback mentioned, the implementation is not in the right place. The viable options are in |
I think this might give incorrect answers for values near the int64 bounds because casting to float will be lossy. Can you add a test for that? |
closing as stale. if you'd like to continue, pls ping. |
git diff upstream/master -u -- "*.py" | flake8 --diff