Code Sample, a copy-pastable example if possible

import numpy as np
import pandas as pd

df = pd.DataFrame(np.random.rand(10,3))
df['col'] = 'A'
df.div(df.iloc[:, 0], axis = 0)

Problem description

This throws the following error:

Traceback (most recent call last):

  File "<ipython-input-22-b922d0177cba>", line 5, in <module>
    df.div(df.iloc[:, 0], axis = 0)

  File "C:\Users\flabriol\AppData\Local\Continuum\Anaconda2\lib\site-packages\pandas\core\ops.py", line 1062, in f
    return self._combine_series(other, na_op, fill_value, axis, level)

  File "C:\Users\flabriol\AppData\Local\Continuum\Anaconda2\lib\site-packages\pandas\core\frame.py", line 3510, in _combine_series
    fill_value=fill_value)

  File "C:\Users\flabriol\AppData\Local\Continuum\Anaconda2\lib\site-packages\pandas\core\frame.py", line 3535, in _combine_match_index
    return self._constructor(func(left.values.T, right.values).T,

  File "C:\Users\flabriol\AppData\Local\Continuum\Anaconda2\lib\site-packages\pandas\core\ops.py", line 993, in na_op
    mask = notnull(xrav) & notnull(yrav)

**ValueError: operands could not be broadcast together with shapes (40,) (10,)** 

Expected Output

I had hard time understanding this error has nothing to do with the shape of the columns but with their dtypes.

Probably a TypeError like TypeError: Could not operate 1.0 with block values unsupported operand type(s) for /: 'str' and 'float' would have been better

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 2.7.12.final.0 python-bits: 64 OS: Windows OS-release: 7 machine: AMD64 processor: Intel64 Family 6 Model 44 Stepping 2, GenuineIntel byteorder: little LC_ALL: None LANG: en pandas: 0.18.1 nose: 1.3.7 pip: 9.0.1 setuptools: 27.2.0 Cython: 0.25.2 numpy: 1.11.1 scipy: 0.17.1 statsmodels: None xarray: None IPython: 4.2.0 sphinx: 1.4.1 patsy: 0.4.1 dateutil: 2.5.3 pytz: 2016.4 blosc: 1.4.4 bottleneck: 1.1.0 tables: 3.2.2 numexpr: 2.6.0 matplotlib: 2.0.0 openpyxl: 2.3.2 xlrd: 1.0.0 xlwt: 1.1.2 xlsxwriter: 0.9.2 lxml: 3.6.0 bs4: 4.4.1 html5lib: None httplib2: None apiclient: None sqlalchemy: 1.0.13 pymysql: None psycopg2: None jinja2: 2.8 boto: 2.40.0 pandas_datareader: None

Comment From: gfyoung

@FXLab91 : I ran this code myself, and the first exception that I get is in fact regarding dtypes. The second exception is the one that you get.

Could you check your output / stacktrace to see whether you get more than just that one error message?

Comment From: FXLab91

@gfyoung : I tried to run the code again, but the stacktrace is just what I reported in the first post. I am running it on iPython console, should it matter.

capture

Comment From: gfyoung

1) It should not matter. I ran the code in IPython as well, and I can see both errors. It could be that your sys.tracebacklimit is too small for all the error messages to be displayed.

2) I see you are using pandas 0.18.1. We are in fact now at 0.20.3 - perhaps the discrepancy is due to the fact that you have a very old pandas version. Could you try upgrading and see if that helps?

Comment From: gfyoung

@FXLab91 : Did my upgrade (or any of my) suggestion(s) help? (I see you :+1: my comment)

Comment From: gfyoung

Closing as I can't reproduce the issue. Please ping this issue again if it rears its head once more. Thanks!