Skip to content

ops._arith_method_FRAME typo? #19421

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

Closed
jbrockmendel opened this issue Jan 27, 2018 · 1 comment · Fixed by #19448
Closed

ops._arith_method_FRAME typo? #19421

jbrockmendel opened this issue Jan 27, 2018 · 1 comment · Fixed by #19448

Comments

@jbrockmendel
Copy link
Member

https://github.com/pandas-dev/pandas/blob/master/pandas/core/ops.py#L1030

                # we may need to manually
                # broadcast a 1 element array
                if yrav.shape != mask.shape:
                    yrav = np.empty(mask.shape, dtype=yrav.dtype)
                    yrav.fill(yrav.item())

Getting yrav.item() in the last line here after re-defining yrav in the previous line seems like it is likely getting the wrong thing. Is this intentional?

@jbrockmendel
Copy link
Member Author

It looks like in the tests this branch is only hit in py3 and in one test:

s = Series([2, 3, 4, 5, 6, 7, 8, 9, datetime(2005, 1, 1)])
s[::2] = np.nan
d = DataFrame({'A': s})

with pytest.raises(ValueError):
    d.__and__(s, axis='columns')

... and the reason why a ValueError is raised ATM is because the call to yrav.item() raises ValueError: can only convert an array of size 1 to a Python scalar

So still not sure what's going on, but increasingly confident this isn't how it is supposed to work.

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 a pull request may close this issue.

1 participant