Skip to content

ENH: add iso-format support to to_timedelta (#21877) #21933

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 4 commits into from
Jul 20, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pandas/tests/indexes/timedeltas/test_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def test_constructor(self):
tm.assert_index_equal(TimedeltaIndex([400, 450, 1200], unit='ms'),
expected)

def test_constructor_iso(self):
expected = timedelta_range('1s', periods=9, freq='s')
durations = ['P0DT0H0M{}S'.format(i) for i in range(1, 10)]
tm.assert_index_equal(to_timedelta(durations), expected)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit but we have a pseudo-standard of doing tm.assert_index_equal(result, expected) so would be nice to assign to a variable called result in the line above and simply do the comparison on the last line

Copy link
Member

@gfyoung gfyoung Jul 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More importantly, you should reference the issue number in a comment beyond the function def line.

Same applies to all tests that you have added.


def test_constructor_coverage(self):
rng = timedelta_range('1 days', periods=10.5)
exp = timedelta_range('1 days', periods=10)
Expand Down