-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
to_pickle compression does not work with in-memory buffers #26237
Comments
closes #290 (see also pandas-dev/pandas#26237)
Is it correct that |
Ah just realized that to_pickle is only documented as supporting a str argument to the path, so the fact that it worked before on a buffer was an implementation detail. That said most of the IO methods support buffers so I think should be possible to extend that here and document accordingly |
this is a duplicate: #5924 |
I'm still having this error. When I add ", compression=None)" I get the following error instead: TypeError Traceback (most recent call last) ~/miniconda3/lib/python3.7/site-packages/pandas/io/pickle.py in read_wrapper(func) ~/miniconda3/lib/python3.7/site-packages/pandas/io/pickle.py in (f) TypeError: file must have 'read' and 'readline' attributes During handling of the above exception, another exception occurred: AttributeError Traceback (most recent call last) ~/miniconda3/lib/python3.7/site-packages/pandas/io/pickle.py in read_wrapper(func) ~/miniconda3/lib/python3.7/site-packages/pandas/io/pickle.py in (f) ~/miniconda3/lib/python3.7/site-packages/pandas/compat/pickle_compat.py in load(fh, encoding, compat, is_verbose) ~/miniconda3/lib/python3.7/site-packages/pandas/core/generic.py in getattr(self, name) AttributeError: 'DataFrame' object has no attribute 'seek' |
This is the error I get without adding compression=None "--------------------------------------------------------------------------- ~/miniconda3/lib/python3.7/site-packages/pandas/io/pickle.py in read_wrapper(func) ~/miniconda3/lib/python3.7/site-packages/pandas/io/common.py in _get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text) ValueError: Unrecognized compression type: infer" |
@dqii are you using the minimal code snippet I shared above? What is your pandas version and Python version? |
Sorry on reflection I realized my error might be different. I was saving a large pandas dataframe. My pandas version is 0.24.2 and my Python version is 3.7.3. I made a separate thread for my issue in #27029. Sorry about that! |
I agree with WillAyd, |
The original bug, to_pickle() to a buffer not working with compression='infer' appears to still be broken in the current dev branch, and the fix seems to be very simple. If there isn't a reason it hasn't been fixed, I can provide a PR. |
Code Sample, a copy-pastable example if possible
Problem description
#22555 is closely related, but I believe this is a different issue because the errors occur at a different place in the code.
I believe the above is an issue because
path : string File path
, the code contains multiplepath_or_buf
names. I'd be happy to make a PR amending the docstring if anybody confirms that the docstring is not precise.compression='infer'
failing is a regressionOutput of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.7.1.final.0
python-bits: 64
OS: Linux
OS-release: 5.0.0-13-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.24.2
pytest: 4.4.1
pip: 19.1
setuptools: 41.0.1
Cython: 0.29.7
numpy: 1.16.3
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 7.5.0
sphinx: None
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2019.1
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.3
openpyxl: None
xlrd: 1.2.0
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: 4.7.1
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
The text was updated successfully, but these errors were encountered: