Skip to content
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

Merged
merged 19 commits into from
Mar 5, 2021
Merged

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Mar 3, 2021

xref #39146

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Can you do a search for TODO(ArrayManager) quantile ? There should be a bunch that can be removed I think

) -> ArrayManager:

arrs = [
x if not isinstance(x, np.ndarray) else np.atleast_2d(x)
Copy link
Member

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)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one (potentially)

Copy link
Member Author

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

@@ -526,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"])
Copy link
Member

Choose a reason for hiding this comment

The 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

if not using_array_manager:
    assert len(df._mgr.blocks) == 2

because I think the rest of the test is still valid

@@ -554,13 +554,6 @@ def quantile(
for blk in self.blocks
]

if transposed:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transposed keyword is no longer used after removing this? (so the keyword can be removed as well)

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# TODO: this casting should be unnecessary after GH#39763 is fixed
# TODO(ArrayManager) this casting should be unnecessary after GH#39763 is fixed

@gfyoung gfyoung added Enhancement Numeric Operations Arithmetic, Comparison, and Logical operations labels Mar 4, 2021
@jbrockmendel
Copy link
Member Author

comments addressed i think



def quantile_ea_compat(
values: ExtensionArray, qs, interpolation: str, axis: int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is all super gross. i guess moving it here and then going to clean in future?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depends on a few things: this can become somewhat less gross with 2D EAs (or 1D ndarrays in an ArrayManager world). There's also the fact that values_for_factorize used here doesnt work for IntegerArray/FloatingArray.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be better if we expose a .quantile() on EAs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that may eventually be the way to go. will see if thats what it takes to get the IntegerArray/FloatingArray working again

@jreback
Copy link
Contributor

jreback commented Mar 5, 2021

can you merge master

@jbrockmendel
Copy link
Member Author

can you merge master

rebased+greenish

@jreback jreback added this to the 1.3 milestone Mar 5, 2021
@jreback jreback merged commit af0a60e into pandas-dev:master Mar 5, 2021
@jbrockmendel jbrockmendel deleted the ref-quantile-2 branch March 5, 2021 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants