Skip to content

Conversation

@weikai202
Copy link

Fixes #59053.

Series.clip(lower=np.array(0)) and similar cases failed because 0-d numpy
arrays were treated as array-like objects, and the code attempted to call
len() on them, which raises TypeError: len() of unsized object.

This PR:

  • detects 0-d numpy arrays and unwraps them using lib.item_from_zerodim
    so they behave like scalars;
  • preserves existing behavior for true array-like inputs (1-d arrays, lists, tuples);
  • adds tests ensuring that both lower and upper accept 0-d numpy arrays
    and produce the expected clipped result.

All tests for the modified functions pass on CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Series.clip does not work with scalar numpy arrays.

1 participant