Skip to content

BUG : assignment of non-ns timedelta64 value (GH14155) #14160

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

Closed
wants to merge 1 commit into from

Conversation

rsmith54
Copy link

@rsmith54 rsmith54 commented Sep 6, 2016

@@ -1696,7 +1696,7 @@ def _try_coerce_args(self, values, other):
other = other.value
elif isinstance(other, np.timedelta64):
other_mask = isnull(other)
other = other.view('i8')
other = Timedelta(np.timedelta64(other))
Copy link
Contributor

Choose a reason for hiding this comment

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

use Timedelta(other).value

Copy link
Member

@jorisvandenbossche jorisvandenbossche Sep 6, 2016

Choose a reason for hiding this comment

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

Can you address this one? (EDIT not the .value part, but the timedelta64 part)
The np.timedelta64(..) is not needed given you just tested that it is already a np.timedelta64 object

@jreback
Copy link
Contributor

jreback commented Sep 6, 2016

tests might be in tseries/test_timedelta.py but more likely in index/test_indexing.py

@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves Timedelta Timedelta data type labels Sep 6, 2016
@codecov-io
Copy link

codecov-io commented Sep 6, 2016

Current coverage is 85.24% (diff: 100%)

Merging #14160 into master will not change coverage

@@             master     #14160   diff @@
==========================================
  Files           140        140          
  Lines         50549      50549          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits          43091      43091          
  Misses         7458       7458          
  Partials          0          0          

Powered by Codecov. Last update 1ace12b...dce11f0

@rsmith54
Copy link
Author

rsmith54 commented Sep 6, 2016

Added the call to other, and added a test in tests/series/test_indexing.py. Please let me know if there is any other comments or changes needed.

@@ -1478,3 +1478,4 @@ Bug Fixes

- Bug in ``eval()`` where the ``resolvers`` argument would not accept a list (:issue:`14095`)
- Bugs in ``stack``, ``get_dummies``, ``make_axis_dummies`` which don't preserve categorical dtypes in (multi)indexes (:issue:`13854`)
- Bug in ``internals._try_coerce_args``, when setting ```Timedelta``` with ```ix``` (:issue:`14155`)
Copy link
Member

Choose a reason for hiding this comment

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

Can you make this clearer for the user? (specify the user-visible effect of the bug, not the underlying reason)

@jorisvandenbossche jorisvandenbossche changed the title BUG : fix for GH14155 BUG : assignment of non-ns timedelta64 value (GH14155) Sep 6, 2016
@rsmith54 rsmith54 force-pushed the bugfix/GH14155 branch 2 times, most recently from c8452df to a01e131 Compare September 6, 2016 14:27
@rsmith54
Copy link
Author

rsmith54 commented Sep 6, 2016

I have edited the whatsnew to be a bit clearer, changed ix to loc, and fixed the problems with PEP8.

@@ -1696,7 +1696,7 @@ def _try_coerce_args(self, values, other):
other = other.value
elif isinstance(other, np.timedelta64):
other_mask = isnull(other)
other = other.view('i8')
other = Timedelta(np.timedelta64(other)).value
Copy link
Contributor

@jreback jreback Sep 6, 2016

Choose a reason for hiding this comment

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

Timesdelta(other).value is idiomatic; other is already a np.timedelta64

Copy link
Author

Choose a reason for hiding this comment

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

Oops, yep of course. Fixed.

@jreback
Copy link
Contributor

jreback commented Sep 6, 2016

minor comments. lgtm. ping on green.

@rsmith54
Copy link
Author

rsmith54 commented Sep 7, 2016

@jreback , looks like all checks have passed. Let me know if there is anything else I can do.

@jorisvandenbossche
Copy link
Member

@rsmith54 Maybe something went wrong with committing the changes, but it seems the Timedelta(np.timedelta64(other)) has not changed

@jorisvandenbossche jorisvandenbossche added this to the 0.19.0 milestone Sep 7, 2016
@jreback
Copy link
Contributor

jreback commented Sep 7, 2016

lgtm.

@jreback jreback closed this in ff435ba Sep 8, 2016
@jreback
Copy link
Contributor

jreback commented Sep 8, 2016

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug when assigning timedelta64 to a series (or dataframe) with an indexer
4 participants