-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Series with dtype=object does unexpected type conversion #39285
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
ftrihardjo
commented
Jan 20, 2021
•
edited by jreback
Loading
edited by jreback
- closes Series with dtype=object does unexpected type conversion #21881
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
Hello @ftrihardjo! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-01-28 09:55:31 UTC |
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.
pls follow the precommit instructions to lint your code
pandas/tests/series/test_api.py
Outdated
@@ -167,3 +167,15 @@ def test_attrs(self): | |||
s.attrs["version"] = 1 | |||
result = s + 1 | |||
assert result.attrs == {"version": 1} | |||
|
|||
def test_series_with_object_dtype(self): |
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.
these should go in pandas/tests/series/indexing/test_setitem.py
name the test with _empty in its name
pandas/tests/series/test_api.py
Outdated
series = pd.Series([], dtype=object) | ||
series["timestamp"] = timestamp | ||
expected = type(series.timestamp) | ||
series = pd.Series([], dtype=object) |
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.
blank line between cases
pandas/tests/series/test_api.py
Outdated
timestamp = pd.Timestamp(1412526600000000000) | ||
series = pd.Series([], dtype=object) | ||
series["timestamp"] = timestamp | ||
expected = type(series.timestamp) |
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.
explcity construct the result series and use tm.assert_series_equal
series["anything"] = 300.0 | ||
series["timestamp"] = timestamp | ||
result = series["timestamp"] | ||
assert isinstance(result, Timestamp) and isinstance(expected, Timestamp) |
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
assert result == expected
thanks @ftrihardjo |