-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
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.
lgtm. mostly style comments. ping on green.
doc/source/whatsnew/v0.22.0.txt
Outdated
@@ -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`) |
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.
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 |
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.
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]') |
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.
add the issue number here as a commet
|
||
@pytest.mark.parametrize( | ||
"value, expected", | ||
[(None, [pd.NaT, 1, 2]), |
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.
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): |
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.
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]') |
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.
test with .loc
as well
Hello, ok will fix that. Also, additional commits should be combined into one? |
you don’t need to combine you can just push more |
thanks @fjdiod |
…andas-dev#18586) (cherry picked from commit 0e16818)
git diff upstream/master -u -- "*.py" | flake8 --diff