-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: add timedelta as valid type for interpolate with method='time' #14799
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
Changes from 6 commits
d87273d
822f55e
81dab58
18b756c
95722ff
579c4bb
b72ab91
fff59f5
562a793
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -891,6 +891,23 @@ def test_spline_error(self): | |
with tm.assertRaises(ValueError): | ||
s.interpolate(method='spline', order=0) | ||
|
||
def test_interp_timedelta64(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add another test with non-uniform spacing in the index. e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, would it be better if i add it as one more in the existing test or as a new test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TomAugspurger i have added non uniform spacing as a test case now |
||
# GH 6424 | ||
df = Series([1, np.nan, 3], | ||
index=pd.to_timedelta([1, 2, 3])) | ||
result = df.interpolate(method='time') | ||
expected = Series([1., 2., 3.], | ||
index=pd.to_timedelta([1, 2, 3])) | ||
assert_series_equal(result, expected) | ||
|
||
# test for non uniform spacing | ||
df = Series([1, np.nan, 3], | ||
index=pd.to_timedelta([1, 2, 4])) | ||
result = df.interpolate(method='time') | ||
expected = Series([1., 1.666667, 3.], | ||
index=pd.to_timedelta([1, 2, 4])) | ||
assert_series_equal(result, expected) | ||
|
||
|
||
if __name__ == '__main__': | ||
import nose | ||
|
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.
with
method='time'
(also space before(:issue:...