BUG: division misbehaving · Issue #7325 · pandas-dev/pandas (original) (raw)
>>> df = pd.DataFrame(np.arange(3*2).reshape((3,2)))
>>> df
0 1
0 0 1
1 2 3
2 4 5
>>> df.add(df[0], axis='index')
0 1
0 0 1
1 4 5
2 8 9
>>> df.sub(df[0], axis='index')
0 1
0 0 1
1 0 1
2 0 1
>>> df.mul(df[0], axis='index')
0 1
0 0 0
1 4 6
2 16 20
>>> df.div(df[0], axis='index')
Traceback (most recent call last):
File "<ipython-input-47-5b698f939cc6>", line 1, in <module>
df.div(df[0], axis='index')
File "/usr/local/lib/python2.7/dist-packages/pandas-0.14.0_5_g3b82634-py2.7-linux-x86_64.egg/pandas/core/ops.py", line 763, in f
return self._combine_series(other, na_op, fill_value, axis, level)
File "/usr/local/lib/python2.7/dist-packages/pandas-0.14.0_5_g3b82634-py2.7-linux-x86_64.egg/pandas/core/frame.py", line 2830, in _combine_series
return self._combine_match_index(other, func, level=level, fill_value=fill_value)
File "/usr/local/lib/python2.7/dist-packages/pandas-0.14.0_5_g3b82634-py2.7-linux-x86_64.egg/pandas/core/frame.py", line 2860, in _combine_match_index
return self._constructor(func(left.values.T, right.values).T,
File "/usr/local/lib/python2.7/dist-packages/pandas-0.14.0_5_g3b82634-py2.7-linux-x86_64.egg/pandas/core/ops.py", line 754, in na_op
result = com._fill_zeros(result, x, y, name, fill_zeros)
File "/usr/local/lib/python2.7/dist-packages/pandas-0.14.0_5_g3b82634-py2.7-linux-x86_64.egg/pandas/core/common.py", line 1254, in _fill_zeros
np.putmask(result, mask & ~nans, fill)
ValueError: operands could not be broadcast together with shapes (3,) (6,)
>>> (df*1.0).div((df*1.0)[0], axis='index')
0 1
0 NaN inf
1 1 1.500000
2 1 1.250000
>>> pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-27-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_CA.UTF-8
pandas: 0.14.0-5-g3b82634
nose: 1.3.3
Cython: 0.20.1post0
numpy: 1.8.1
scipy: 0.14.0
statsmodels: 0.5.0
IPython: 1.2.1
sphinx: None
patsy: 0.2.1
scikits.timeseries: None
dateutil: 2.2
pytz: 2014.3
bottleneck: None
tables: None
numexpr: 2.4
matplotlib: 1.3.1
openpyxl: 2.0.3
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: 0.5.5
lxml: 3.3.3
bs4: 4.3.2
html5lib: 0.999
bq: None
apiclient: None
rpy2: None
sqlalchemy: None
pymysql: None
psycopg2: None