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

BUG: ValueError: buffer source array is read-only #37174

Closed
2 tasks
dmitra79 opened this issue Oct 16, 2020 · 0 comments · Fixed by #37181
Closed
2 tasks

BUG: ValueError: buffer source array is read-only #37174

dmitra79 opened this issue Oct 16, 2020 · 0 comments · Fixed by #37181
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Bug
Milestone

Comments

@dmitra79
Copy link

dmitra79 commented Oct 16, 2020

  • I have checked that this issue has not already been reported.

  • [ X ] 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.


This seems similar to: #31710
I am getting it in a dash application, so it's difficult to get an example from there.
However, isin() example from the above post also causes the error:

Code Sample, a copy-pastable example

>>> import numpy as np  # v1.16.4, then v1.18.1
>>> import pandas as pd  # v1.0.1
>>>
>>> arr = np.array([1,2,3], dtype=np.int64) # works fine if I don't set the dtype!
>>>
>>> arr.setflags(write=False) # make it read-only
>>>
>>> df = pd.DataFrame({"col": [2,4,8]})
>>>
>>> test = df.col.isin(arr)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/z0022z7b/anaconda3/envs/mindsynchro/lib/python3.8/site-packages/pandas/core/series.py", line 4685, in isin
    result = algorithms.isin(self, values)
  File "/home/z0022z7b/anaconda3/envs/mindsynchro/lib/python3.8/site-packages/pandas/core/algorithms.py", line 465, in isin
    return f(comps, values)
  File "pandas/_libs/hashtable_func_helper.pxi", line 566, in pandas._libs.hashtable.ismember_int64
  File "stringsource", line 658, in View.MemoryView.memoryview_cwrapper
  File "stringsource", line 349, in View.MemoryView.memoryview.__cinit__
ValueError: buffer source array is read-only

Problem description

The problem is this error. My application code worked fine before, but I had to set it up on a new machine with new pandas and cython a couple days ago, and ran into this.
(Previously I had

  • cython=0.29.14=py37he1b5a44_0
  • pandas=0.24.2=py37he6710b0_0
    Don't know if the isin() example would have thrown an error with that)

Output of pd.show_versions()

'''
INSTALLED VERSIONS

commit : db08276
python : 3.8.6.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-118-generic
Version : #119-Ubuntu SMP Tue Sep 8 12:30:01 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.1.3
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.3
setuptools : 49.6.0.post20201009
Cython : 0.29.21
lxml.etree : 4.5.2
jinja2 : 2.11.2
IPython : 7.18.1
fsspec : 0.8.4
fastparquet : 0.4.1
matplotlib : 3.3.2
pyarrow : 0.17.1
scipy : 1.5.2
xarray : 0.16.1
numba : 0.51.2
'''

@dmitra79 dmitra79 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 16, 2020
@dsaxton dsaxton added Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 17, 2020
@dsaxton dsaxton added this to the 1.2 milestone Oct 17, 2020
@jreback jreback modified the milestones: 1.2, 1.1.4 Oct 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants