Skip to content

BUG: pandas==2.1.0 pickle ArrowStringArrayNumpySemantics failed if pandas.options.future.infer_string = True #55061

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

Closed
2 of 3 tasks
codingl2k1 opened this issue Sep 8, 2023 · 1 comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@codingl2k1
Copy link

Pandas version checks

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

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
pd.options.future.infer_string = True
df = pd.DataFrame({"a": list("123")})
import pickle
pickle.dumps(df.index)
Out[6]: b'\x80\x04\x95\x82\x00\x00\x00\x00\x00\x00\x00\x8c\x18pandas.core.indexes.base\x94\x8c\n_new_Index\x94\x93\x94\x8c\x19pandas.core.indexes.range\x94\x8c\nRangeIndex\x94\x93\x94}\x94(\x8c\x04name\x94N\x8c\x05start\x94K\x00\x8c\x04stop\x94K\x03\x8c\x04step\x94K\x01u\x86\x94R\x94.'
df.index
Out[7]: RangeIndex(start=0, stop=3, step=1)
df.dtypes.index
Out[8]: Index(['a'], dtype='string')
pickle.dumps(df.dtypes.index)

Traceback (most recent call last):
  File "/Users/codingl2k1/.pyenv/versions/3.11.4/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3508, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-9-e0544207018a>", line 1, in <module>
    pickle.dumps(df.dtypes.index)
  File "/Users/codingl2k1/.pyenv/versions/3.11.4/lib/python3.11/site-packages/pandas/core/arrays/arrow/array.py", line 615, in __getstate__
    state = self.__dict__.copy()
            ^^^^^^^^^^^^^
  File "/Users/codingl2k1/.pyenv/versions/3.11.4/lib/python3.11/site-packages/pandas/core/arrays/string_arrow.py", line 461, in __getattribute__
    return partial(getattr(ArrowStringArrayMixin, item), self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: the first argument must be callable

Issue Description

Can't pickle ArrowStringArrayNumpySemantics.

Expected Behavior

pickle / unpickle ArrowStringArrayNumpySemantics is OK.

Installed Versions

INSTALLED VERSIONS

commit : ba1cccd
python : 3.11.4.final.0
python-bits : 64
OS : Darwin
OS-release : 22.6.0
Version : Darwin Kernel Version 22.6.0: Wed Jul 5 22:21:53 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6020
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.UTF-8
pandas : 2.1.0
numpy : 1.24.4
pytz : 2023.3
dateutil : 2.8.2
setuptools : 65.5.0
pip : 23.2.1
Cython : 3.0.2
pytest : 7.4.0
hypothesis : None
sphinx : 4.5.0
blosc : None
feather : None
xlsxwriter : 3.1.2
lxml.etree : 4.9.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.14.0
pandas_datareader : None
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : 2023.6.0
gcsfs : None
matplotlib : 3.7.2
numba : 0.57.1
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : 13.0.0
pyreadstat : None
pyxlsb : None
s3fs : 2023.6.0
scipy : 1.11.1
sqlalchemy : 1.4.49
tables : None
tabulate : 0.9.0
xarray : None
xlrd : 2.0.1
zstandard : 0.21.0
tzdata : 2023.3
qtpy : None
pyqt5 : None

@codingl2k1 codingl2k1 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 8, 2023
@codingl2k1 codingl2k1 changed the title BUG: 2.1.0 pandas.options.future.infer_string = True pickle ArrowStringArrayNumpySemantics failed BUG: pandas==2.1.0 pickle ArrowStringArrayNumpySemantics failed if pandas.options.future.infer_string = True Sep 8, 2023
@phofl
Copy link
Member

phofl commented Sep 8, 2023

Thx for reporting this!

I found this yesterday as well and it's already fixed (will be available in 2.1.1 in 10 days or so)

#55051

@phofl phofl closed this as completed Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

2 participants