-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
ENH: ArrayManager.quantile #40189
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
ENH: ArrayManager.quantile #40189
Changes from 1 commit
003a42d
8dda19b
6743b62
149084d
1748b65
bcd464c
79c2249
4957afe
856b3da
45e776d
33883b1
1c7fe15
9e8405e
1daa18e
926e1c0
34a41d8
0a40767
b0167d2
3d80803
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -554,13 +554,6 @@ def quantile( | |
for blk in self.blocks | ||
] | ||
|
||
if transposed: | ||
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. The |
||
new_axes = new_axes[::-1] | ||
blocks = [ | ||
b.make_block(b.values.T, placement=np.arange(b.shape[1])) | ||
for b in blocks | ||
] | ||
|
||
return type(self)(blocks, new_axes) | ||
|
||
def isna(self, func) -> BlockManager: | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -524,6 +524,7 @@ def test_quantile_empty_no_columns(self): | |||||
expected.columns.name = "captain tightpants" | ||||||
tm.assert_frame_equal(result, expected) | ||||||
|
||||||
@td.skip_array_manager_invalid_test | ||||||
def test_quantile_item_cache(self): | ||||||
# previous behavior incorrect retained an invalid _item_cache entry | ||||||
df = DataFrame(np.random.randn(4, 3), columns=["A", "B", "C"]) | ||||||
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. I can't comment on the exact line (3 lines below), but could also do
because I think the rest of the test is still valid |
||||||
|
@@ -608,12 +609,18 @@ def test_quantile_ea_with_na(self, index, frame_or_series): | |||||
expected = frame_or_series(expected) | ||||||
tm.assert_equal(result, expected) | ||||||
|
||||||
# TODO: filtering can be removed after GH#39763 is fixed | ||||||
@pytest.mark.filterwarnings("ignore:Using .astype to convert:FutureWarning") | ||||||
def test_quantile_ea_all_na(self, index, frame_or_series): | ||||||
|
||||||
obj = frame_or_series(index).copy() | ||||||
|
||||||
obj.iloc[:] = index._na_value | ||||||
|
||||||
# TODO: this casting should be unnecessary after GH#39763 is fixed | ||||||
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.
Suggested change
|
||||||
obj[:] = obj.astype(index.dtype) | ||||||
assert np.all(obj.dtypes == index.dtype) | ||||||
|
||||||
# result should be invariant to shuffling | ||||||
indexer = np.arange(len(index), dtype=np.intp) | ||||||
np.random.shuffle(indexer) | ||||||
|
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.
Can the reshaping be moved to
quantile_compat
? (as it also already does this for EAs)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.
this one (potentially)
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.
i think ArrayManager-specific logic should stay in ArrayManager wherever possible