-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Categorical equality check raises ValueError in DataFrame #12564
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
Comments
here's a simpler example. Yeah I suppose this should work. Note that comparing a vs a DataFrame is not typically useful. You almost always compare against a Series (and then inddex). pull-requests are welcome.
|
My use case, if you want to know, was that I just wanted to discard rows with |
>>> df[['A']].ndim
2
>>> df[['A']]._data.blocks[0].values
array([['foo', 'bar', 'baz']], dtype=object)
>>> df[['A']]._data.blocks[0].values.ndim
2
>>> df[['B']].ndim
2
>>> df[['B']]._data.blocks[0].values
[foo, bar, baz]
Categories (3, object): [bar, baz, foo]
>>> df[['B']]._data.blocks[0].values.ndim
1 interesting, |
@ningchi that is only a manifestation of the issue, not the cause. you can prob get away with changing this:
to something like
|
Thanks, @jreback because On the another hand, is it strange to convert |
did you try the code above? |
@jreback Sorry, I didn't test your suggestion completely. Many thanks. |
Apparently there's an issue when comparing the equality of a scalar value against a categorical column as part of a DataFrame. In the example below, I'm checking against
-np.inf
, but comparing to a string or integer gives the same results.This raises
ValueError: Wrong number of dimensions
.Code Sample
Expected Output
output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: