Skip to content

Conversation

@Amey-sd
Copy link

@Amey-sd Amey-sd commented Jan 22, 2026

Description

Fixed a bug where passing a zero-dimensional numpy array (e.g., np.array(0)) to the clip method caused a TypeError: len() of unsized object.

The issue occurred because the code attempted to check the length of the numpy array without verifying if it had dimensions. This PR updates the logic to treat 0-d arrays as scalars, ensuring they are not iterated over.

I have verified the fix locally and added a regression test case to pandas/tests/series/methods/test_clip.py.

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