-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Index.get_value implementation for ExtensionArray #29926
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 |
---|---|---|
|
@@ -478,3 +478,24 @@ def DecimalArray__my_sum(self): | |
s = pd.Series(DecimalArray(data)) | ||
result = s.groupby(np.array([0, 0, 0, 1, 1])).agg(lambda x: x.values.my_sum()) | ||
tm.assert_series_equal(result, expected, check_names=False) | ||
|
||
|
||
def test_indexing_no_materialize(monkeypatch): | ||
# See https://github.com/pandas-dev/pandas/issues/29708 | ||
# Ensure that indexing operations do not materialize (convert to a numpy | ||
# array) the ExtensionArray unnecessary | ||
|
||
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 make this test more generic (e.g. hit more EA arrays)? |
||
def DecimalArray__array__(self, dtype=None): | ||
raise Exception("tried to convert a DecimalArray to a numpy array") | ||
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 is not fully fool proof, as such an Exception could be catched somewhere in the indexing code. But I at least verified that for the |
||
|
||
monkeypatch.setattr(DecimalArray, "__array__", DecimalArray__array__, raising=False) | ||
|
||
data = make_data() | ||
s = pd.Series(DecimalArray(data)) | ||
df = pd.DataFrame({"a": s, "b": range(len(s))}) | ||
|
||
# ensure the following operations do not raise an error | ||
s[s > 0.5] | ||
df[s > 0.5] | ||
s.at[0] | ||
df.at[0, "a"] |
Uh oh!
There was an error while loading. Please reload this page.