DEPR: allowing unknowns in take by jbrockmendel · Pull Request #52981 · pandas-dev/pandas (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation9 Commits3 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

jbrockmendel

@jbrockmendel

@jbrockmendel

@mroeschke

What's the motivation for this change?

@jbrockmendel

is_array_like is an antipattern #52834

@mroeschke

Seems pretty heavy to deprecate this usage just to avoid is_array_like, especially since numpy.take will accept array-likes. Why can't we just replace not is_array_like with not isinstance(..., (np.ndarray, ...)) and accept we may be calling asarray on more items?

@jbrockmendel

Why can't we just replace not is_array_like with not isinstance(..., (np.ndarray, ...)) and accept we may be calling asarray on more items?

That's a reasonable intuition, but np.asarray can have weird behaviors which we generally work around (but unfortunately have several slightly-different implementations of). My thought is to avoid that by just having the user do that casting.

@rhshadrach

But we'll still allow e.g. a list in DataFrame.take and others? This seems inconsistent.

@jbrockmendel

But we'll still allow e.g. a list in DataFrame.take and others? This seems inconsistent.

This is for the first arg in take, not the indices.

@rhshadrach

I personally wouldn't expect pandas to implement taking from a general sequence (e.g. a list); I'm okay with deprecating from that perspective.

@jbrockmendel

@jbrockmendel

mroeschke

@mroeschke

topper-123 pushed a commit to topper-123/pandas that referenced this pull request

Jun 5, 2023

@jbrockmendel @topper-123

Daquisu pushed a commit to Daquisu/pandas that referenced this pull request

Jul 8, 2023

@jbrockmendel