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

Conversation

fjdiod
Copy link
Contributor

@fjdiod fjdiod commented Jul 16, 2018

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Can you add an indexing test as well to make sure the function appropriately handles multiple timedeltas?

@codecov
Copy link

codecov bot commented Jul 16, 2018

Codecov Report

Merging #21933 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #21933      +/-   ##
==========================================
+ Coverage   91.96%   91.96%   +<.01%     
==========================================
  Files         166      166              
  Lines       50323    50329       +6     
==========================================
+ Hits        46281    46287       +6     
  Misses       4042     4042
Flag Coverage Δ
#multiple 90.36% <ø> (ø) ⬆️
#single 42.23% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/common.py 92.08% <0%> (-0.12%) ⬇️
pandas/core/frame.py 97.19% <0%> (ø) ⬆️
pandas/core/panel.py 97.44% <0%> (ø) ⬆️
pandas/core/series.py 94.11% <0%> (ø) ⬆️
pandas/core/indexes/base.py 96.35% <0%> (ø) ⬆️
pandas/core/reshape/concat.py 97.6% <0%> (ø) ⬆️
pandas/core/sparse/frame.py 94.79% <0%> (+0.01%) ⬆️
pandas/core/sparse/series.py 95.22% <0%> (+0.01%) ⬆️
pandas/core/groupby/generic.py 86.8% <0%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 272bbdc...f0887a8. Read the comment docs.

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.

@gfyoung gfyoung added Enhancement Timedelta Timedelta data type labels Jul 16, 2018
@gfyoung
Copy link
Member

gfyoung commented Jul 16, 2018

@fjdiod : Could you also a whatsnew entry to 0.24.0.txt ? I suspect a mini-section (i.e. not a one-liner but a small section regarding how you can take advantage of this enhancement) will be preferred.

@@ -233,6 +233,11 @@ def check(value):
assert tup.microseconds == 999
assert tup.nanoseconds == 0

def test_iso_convertion(self):
Copy link
Member

Choose a reason for hiding this comment

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

Minor typo of the word conversion if you care to fix up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I push a fix for it?

Copy link
Member

Choose a reason for hiding this comment

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

Go for it

@fjdiod
Copy link
Contributor Author

fjdiod commented Jul 20, 2018

Hello, @WillAyd, could I work on #21140 again now?

@jreback jreback added this to the 0.24.0 milestone Jul 20, 2018
@jreback jreback merged commit 0d858c4 into pandas-dev:master Jul 20, 2018
@jreback
Copy link
Contributor

jreback commented Jul 20, 2018

thanks @fjdiod

@WillAyd
Copy link
Member

WillAyd commented Jul 20, 2018

Go for it - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pd.to_timedelta not parsing iso-formatted strings
4 participants