Skip to content

Commit d8cdcf0

Browse files
Backport PR pandas-dev#35554: DOC: Document that read_hdf can use pickle (pandas-dev#35593)
Co-authored-by: Tom Augspurger <[email protected]>
1 parent a48cc4d commit d8cdcf0

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

doc/source/user_guide/io.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -3441,10 +3441,11 @@ for some advanced strategies
34413441

34423442
.. warning::
34433443

3444-
pandas requires ``PyTables`` >= 3.0.0.
3445-
There is a indexing bug in ``PyTables`` < 3.2 which may appear when querying stores using an index.
3446-
If you see a subset of results being returned, upgrade to ``PyTables`` >= 3.2.
3447-
Stores created previously will need to be rewritten using the updated version.
3444+
Pandas uses PyTables for reading and writing HDF5 files, which allows
3445+
serializing object-dtype data with pickle. Loading pickled data received from
3446+
untrusted sources can be unsafe.
3447+
3448+
See: https://docs.python.org/3/library/pickle.html for more.
34483449

34493450
.. ipython:: python
34503451
:suppress:

pandas/io/pytables.py

+50-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,15 @@ def read_hdf(
289289
Read from the store, close it if we opened it.
290290
291291
Retrieve pandas object stored in file, optionally based on where
292-
criteria
292+
criteria.
293+
294+
.. warning::
295+
296+
Pandas uses PyTables for reading and writing HDF5 files, which allows
297+
serializing object-dtype data with pickle when using the "fixed" format.
298+
Loading pickled data received from untrusted sources can be unsafe.
299+
300+
See: https://docs.python.org/3/library/pickle.html for more.
293301
294302
Parameters
295303
----------
@@ -445,6 +453,14 @@ class HDFStore:
445453
446454
Either Fixed or Table format.
447455
456+
.. warning::
457+
458+
Pandas uses PyTables for reading and writing HDF5 files, which allows
459+
serializing object-dtype data with pickle when using the "fixed" format.
460+
Loading pickled data received from untrusted sources can be unsafe.
461+
462+
See: https://docs.python.org/3/library/pickle.html for more.
463+
448464
Parameters
449465
----------
450466
path : str
@@ -789,6 +805,14 @@ def select(
789805
"""
790806
Retrieve pandas object stored in file, optionally based on where criteria.
791807
808+
.. warning::
809+
810+
Pandas uses PyTables for reading and writing HDF5 files, which allows
811+
serializing object-dtype data with pickle when using the "fixed" format.
812+
Loading pickled data received from untrusted sources can be unsafe.
813+
814+
See: https://docs.python.org/3/library/pickle.html for more.
815+
792816
Parameters
793817
----------
794818
key : str
@@ -852,6 +876,15 @@ def select_as_coordinates(
852876
"""
853877
return the selection as an Index
854878
879+
.. warning::
880+
881+
Pandas uses PyTables for reading and writing HDF5 files, which allows
882+
serializing object-dtype data with pickle when using the "fixed" format.
883+
Loading pickled data received from untrusted sources can be unsafe.
884+
885+
See: https://docs.python.org/3/library/pickle.html for more.
886+
887+
855888
Parameters
856889
----------
857890
key : str
@@ -876,6 +909,14 @@ def select_column(
876909
return a single column from the table. This is generally only useful to
877910
select an indexable
878911
912+
.. warning::
913+
914+
Pandas uses PyTables for reading and writing HDF5 files, which allows
915+
serializing object-dtype data with pickle when using the "fixed" format.
916+
Loading pickled data received from untrusted sources can be unsafe.
917+
918+
See: https://docs.python.org/3/library/pickle.html for more.
919+
879920
Parameters
880921
----------
881922
key : str
@@ -912,6 +953,14 @@ def select_as_multiple(
912953
"""
913954
Retrieve pandas objects from multiple tables.
914955
956+
.. warning::
957+
958+
Pandas uses PyTables for reading and writing HDF5 files, which allows
959+
serializing object-dtype data with pickle when using the "fixed" format.
960+
Loading pickled data received from untrusted sources can be unsafe.
961+
962+
See: https://docs.python.org/3/library/pickle.html for more.
963+
915964
Parameters
916965
----------
917966
keys : a list of the tables

0 commit comments

Comments
 (0)