-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Series.get() with ExtensionArray and integer index #21260
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 2 commits
16e1a8b
f9401ab
53687b0
90661bb
2d7c526
0854a06
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 |
---|---|---|
|
@@ -998,6 +998,42 @@ def test_validate_bool_args(self): | |
with pytest.raises(ValueError): | ||
self.int_series.drop_duplicates(inplace=value) | ||
|
||
def test_get(self): | ||
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. this should be in pandas/tests/series/test_indexing (and pandas/tests/frame/test_indexing) 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. Moved it to pandas/tests/series/indexing/test_indexing and parameterized the test Note for dataframes, |
||
for o in self.objs: | ||
if isinstance(o, Series): | ||
s = o.set_axis([2 * i for i in range(len(o))], inplace=False) | ||
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. just directly construct a Series with the provided values rather than trying to convolute this 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. done |
||
assert s.get(4) == s.iloc[2] | ||
|
||
result = s.get([4, 6]) | ||
expected = s.iloc[[2, 3]] | ||
tm.assert_series_equal(result, expected) | ||
|
||
result = s.get(slice(2)) | ||
expected = s.iloc[[0, 1]] | ||
tm.assert_series_equal(result, expected) | ||
|
||
assert s.get(-1) is None | ||
assert s.get(s.index.max() + 1) is None | ||
|
||
s = Series(o.values[:6], index=list('abcdef')) | ||
assert s.get('c') == s.iloc[2] | ||
|
||
result = s.get(slice('b', 'd')) | ||
expected = s.iloc[[1, 2, 3]] | ||
tm.assert_series_equal(result, expected) | ||
|
||
result = s.get('Z') | ||
assert result is None | ||
|
||
assert s.get(4) == s.iloc[4] | ||
assert s.get(-1) == s.iloc[-1] | ||
assert s.get(len(s)) is None | ||
|
||
# GH 21257 | ||
s = pd.Series(o.values) | ||
s2 = s[::2] | ||
assert s2.get(1) is None | ||
|
||
|
||
class TestTranspose(Ops): | ||
errmsg = "the 'axes' parameter is not supported" | ||
|
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.
move to 0.24.0
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.
done