-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: numpy functions (eg, np.add) on DataFrames with 'out' parameter no longer work properly #40662
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
Suggest adding the [Regression] label (appears I am unable to do so). |
I confirm this is a bug on master. I think the issue is in pandas/core/arraylike.py Changing lines 350-362 from:
to:
seems to fix this problem. |
Just ran into this bug when using |
@attack68 that seems like the correct fix, thanks for the investigation! Want to do a PR for that? (then we can include it for 1.2.4) |
The change in 1.2 that maybe the cause the regression (I'll check shortly) is that In 1.1.5, so it maybe that |
I think at least for the sake of consistency, passing |
|
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Problem description
Many numpy functions accept an
out
parameter as a way of storing the result. In the current pandas version (1.2.3), when the numpy function takes in a DataFrame as input, it no longer stores the result to theout
array.In pandas 1.0.1 (and earlier, on my other machine), the behavior works as expected. (see Expected Output). I am using numpy==1.19 for both machines.
Curiously, note that this problem is not seen for
pd.Series
. The below code works fine:One workaround is to instead use
np.add(df.values, 1, out=bar)
but I am using several packages that require the older behavior.Expected Output
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : f2c8480
python : 3.7.4.final.0
python-bits : 64
OS : Linux
OS-release : 3.10.0-1062.1.1.el7.x86_64
Version : #1 SMP Fri Sep 13 22:55:44 UTC 2019
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 1.2.3
numpy : 1.19.5
pytz : 2019.3
dateutil : 2.8.1
pip : 19.3.1
setuptools : 41.4.0
Cython : 0.29.21
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.0
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.11.1
pandas_datareader: None
bs4 : 4.9.1
bottleneck : None
fsspec : 0.8.2
fastparquet : None
gcsfs : None
matplotlib : 3.1.3
numexpr : 2.7.0
odfpy : None
openpyxl : 3.0.4
pandas_gbq : None
pyarrow : 0.13.0
pyxlsb : None
s3fs : 0.5.1
scipy : 1.4.1
sqlalchemy : 1.3.13
tables : 3.6.1
tabulate : 0.8.7
xarray : None
xlrd : 1.2.0
xlwt : None
numba : 0.49.1
The text was updated successfully, but these errors were encountered: