-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. don't import this, use |
||
|
||
|
||
class TestTimedeltaIndexing(object): | ||
|
@@ -47,3 +48,14 @@ def test_string_indexing(self): | |
expected = df.iloc[0] | ||
sliced = df.loc['0 days'] | ||
tm.assert_series_equal(sliced, expected) | ||
|
||
@pytest.mark.parametrize( | ||
"value, expected", | ||
[(None, [pd.NaT, 1, 2]), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
(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 commentThe reason will be displayed to describe this comment to others. Learn more. name this like: test_masked_setitem |
||
series = pd.Series([0, 1, 2], dtype='timedelta64[ns]') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add the issue number here as a commet |
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. test with |
||
tm.assert_series_equal(series, 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.
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]
dtypeSeries
with aTimedelta
incorrectly coerced to float.