-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: appending a Timedelta to Series incorrectly casts to integer #27303
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 all commits
864c32b
82cfca4
e4e6629
2c6d922
d1b06fc
9feab49
4731aaf
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 |
---|---|---|
|
@@ -654,6 +654,29 @@ def test_timedelta_assignment(): | |
tm.assert_series_equal(s, expected) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"td", | ||
[ | ||
pd.Timedelta("9 days"), | ||
pd.Timedelta("9 days").to_timedelta64(), | ||
pd.Timedelta("9 days").to_pytimedelta(), | ||
], | ||
) | ||
def test_append_timedelta_does_not_cast(td): | ||
# GH#22717 inserting a Timedelta should _not_ cast to int64 | ||
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. new test pls & parameterize over timedelta & np.timedelta64 as wel |
||
expected = pd.Series(["x", td], index=[0, "td"], dtype=object) | ||
|
||
ser = pd.Series(["x"]) | ||
ser["td"] = td | ||
tm.assert_series_equal(ser, expected) | ||
assert isinstance(ser["td"], pd.Timedelta) | ||
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. Lost previous comment but can you use 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. will do 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. can you compare vs the expected series instead |
||
|
||
ser = pd.Series(["x"]) | ||
ser.loc["td"] = pd.Timedelta("9 days") | ||
tm.assert_series_equal(ser, expected) | ||
assert isinstance(ser["td"], pd.Timedelta) | ||
|
||
|
||
def test_underlying_data_conversion(): | ||
# GH 4080 | ||
df = DataFrame({c: [1, 2, 3] for c in ["a", "b", "c"]}) | ||
|
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.
should really put this in a test_timedelta.py (and take the existing tests out of test_indexing).
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.
after the current batch of PRs I'm planning on doing a review of the indexing tests. There are multiple dimensions along which we can sort/parametrize, any of which would be reasonable, but my guess is we are not being consistent about it.