Skip to content

BUG: Unwanted conversion from timedelta to float (#18493) #18586

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
Dec 2, 2017

Conversation

fjdiod
Copy link
Contributor

@fjdiod fjdiod commented Dec 1, 2017

@codecov
Copy link

codecov bot commented Dec 1, 2017

Codecov Report

Merging #18586 into master will decrease coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18586      +/-   ##
==========================================
- Coverage   91.46%   91.43%   -0.04%     
==========================================
  Files         157      157              
  Lines       51438    51379      -59     
==========================================
- Hits        47046    46976      -70     
- Misses       4392     4403      +11
Flag Coverage Δ
#multiple 89.29% <100%> (-0.02%) ⬇️
#single 40.56% <100%> (-0.13%) ⬇️
Impacted Files Coverage Δ
pandas/core/internals.py 94.47% <100%> (ø) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/util/testing.py 81.6% <0%> (-0.29%) ⬇️
pandas/core/indexes/datetimelike.py 96.91% <0%> (-0.2%) ⬇️
pandas/core/generic.py 95.78% <0%> (-0.13%) ⬇️
pandas/core/reshape/merge.py 94.29% <0%> (-0.12%) ⬇️
pandas/core/frame.py 97.81% <0%> (-0.1%) ⬇️
pandas/core/series.py 94.76% <0%> (-0.05%) ⬇️
pandas/core/groupby.py 92.04% <0%> (ø) ⬆️
pandas/core/base.py 96.55% <0%> (ø) ⬆️
... and 3 more

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 e1ba19a...492889b. Read the comment docs.

@jreback jreback added Bug Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves Timedelta Timedelta data type labels Dec 1, 2017
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm. mostly style comments. ping on green.

@@ -151,7 +151,7 @@ Indexing
- Bug in :class:`IntervalIndex` where empty and purely NA data was constructed inconsistently depending on the construction method (:issue:`18421`)
- Bug in ``IntervalIndex.symmetric_difference()`` where the symmetric difference with a non-``IntervalIndex`` did not raise (:issue:`18475`)
- Bug in indexing a datetimelike ``Index`` that raised ``ValueError`` instead of ``IndexError`` (:issue:`18386`).

- Bug in ``TimeDeltaBlock._can_hold_element()`` where masked assignment of a timedelta series converts the series values to float64 (:issue:`18493`)
Copy link
Contributor

Choose a reason for hiding this comment

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

you can move to 0.21.1

don't use internal language here, these are user-level notes. So say something like

Bug in masked assignment of a timedelta64[ns] dtype Series with a Timedelta incorrectly coerced to float.

@@ -2,6 +2,7 @@

import pandas as pd
from pandas.util import testing as tm
from numpy import nan
Copy link
Contributor

Choose a reason for hiding this comment

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

don't import this, use np.nan

(pd.NaT, [pd.NaT, 1, 2]),
(nan, [pd.NaT, 1, 2])])
def test_nan(self, value, expected):
series = pd.Series([0, 1, 2], dtype='timedelta64[ns]')
Copy link
Contributor

Choose a reason for hiding this comment

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

add the issue number here as a commet


@pytest.mark.parametrize(
"value, expected",
[(None, [pd.NaT, 1, 2]),
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need to pass expected here as they are the same, just define in the body

[(None, [pd.NaT, 1, 2]),
(pd.NaT, [pd.NaT, 1, 2]),
(nan, [pd.NaT, 1, 2])])
def test_nan(self, value, expected):
Copy link
Contributor

Choose a reason for hiding this comment

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

name this like: test_masked_setitem

def test_nan(self, value, expected):
series = pd.Series([0, 1, 2], dtype='timedelta64[ns]')
series[series == series[0]] = value
expected = pd.Series([pd.NaT, 1, 2], dtype='timedelta64[ns]')
Copy link
Contributor

Choose a reason for hiding this comment

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

test with .loc as well

@fjdiod
Copy link
Contributor Author

fjdiod commented Dec 1, 2017

Hello, ok will fix that. Also, additional commits should be combined into one?

@jreback
Copy link
Contributor

jreback commented Dec 1, 2017

you don’t need to combine you can just push more

@jreback jreback added this to the 0.21.1 milestone Dec 2, 2017
@jreback jreback merged commit 0e16818 into pandas-dev:master Dec 2, 2017
@jreback
Copy link
Contributor

jreback commented Dec 2, 2017

thanks @fjdiod

TomAugspurger pushed a commit to TomAugspurger/pandas that referenced this pull request Dec 8, 2017
TomAugspurger pushed a commit that referenced this pull request Dec 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions 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.

Unwanted conversion from timedelta to float (but not datetime)
3 participants