Skip to content

ERR: Raise a better error for numpy singletons in Index #33026

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

Merged
merged 5 commits into from
Mar 26, 2020
Merged

ERR: Raise a better error for numpy singletons in Index #33026

merged 5 commits into from
Mar 26, 2020

Conversation

dsaxton
Copy link
Member

@dsaxton dsaxton commented Mar 25, 2020

elif data is None or is_scalar(data):
raise cls._scalar_data_error(data)
elif hasattr(data, "__array__"):
return Index(np.asarray(data), dtype=dtype, copy=copy, name=name, **kwargs)
Copy link
Member Author

Choose a reason for hiding this comment

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

Just checking for scalars before testing for an __array__ attribute since things like np.array([1, 2])[0] pass both

@WillAyd WillAyd added the Error Reporting Incorrect or improved errors from pandas label Mar 26, 2020
@WillAyd
Copy link
Member

WillAyd commented Mar 26, 2020

lgtm - can you add a whatsnew?

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

sorry one more nit otherwise lgtm

@jreback jreback added this to the 1.1 milestone Mar 26, 2020
@jreback jreback added the Index Related to the Index class or subclasses label Mar 26, 2020
@jreback jreback merged commit c81d90f into pandas-dev:master Mar 26, 2020
@jreback
Copy link
Contributor

jreback commented Mar 26, 2020

thanks @dsaxton

@dsaxton dsaxton deleted the better-error branch March 26, 2020 13:31
@JoElfner
Copy link
Contributor

Many thanks! That was a quick fix! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unspecific error message when setting singular index with np dtype
4 participants