Skip to content
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

Mixed-dtype dataframe comparison with array raises incorrectly #20090

Closed
jbrockmendel opened this issue Mar 10, 2018 · 0 comments · Fixed by #22880 or #23132
Closed

Mixed-dtype dataframe comparison with array raises incorrectly #20090

jbrockmendel opened this issue Mar 10, 2018 · 0 comments · Fixed by #22880 or #23132
Labels
Numeric Operations Arithmetic, Comparison, and Logical operations Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@jbrockmendel
Copy link
Member

This came up while going through some of statsmodels tests:

arr = np.random.randn(3, 2)
arr[:, 0] = [1, 2, 3]
df = pd.DataFrame(arr)
df[0] = df[0].astype(int)
>>> df == arr
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pandas/core/ops.py", line 1572, in f
    try_cast=False)
  File "pandas/core/frame.py", line 4021, in _combine_const
    try_cast=try_cast)
  File "pandas/core/internals.py", line 3644, in eval
    return self.apply('eval', **kwargs)
  File "pandas/core/internals.py", line 3538, in apply
    applied = getattr(b, f)(**kwargs)
  File "pandas/core/internals.py", line 1348, in eval
    t_shape=values.T.shape, oth_shape=other.shape))
ValueError: cannot broadcast shape [(3, 1)] with block values [(3, 2)]

I'd expect this to wrap the ndarray in a frame and return an all-True frame.

gfyoung pushed a commit that referenced this issue Oct 13, 2018
@jreback jreback added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Numeric Operations Arithmetic, Comparison, and Logical operations labels Oct 14, 2018
@jreback jreback added this to the 0.24.0 milestone Oct 14, 2018
tm9k1 pushed a commit to tm9k1/pandas that referenced this issue Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Numeric Operations Arithmetic, Comparison, and Logical operations Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
2 participants