sql.html)
    * [ pandas.read_gbq ](pandas.read_gbq.html)
    * [ pandas.read_stata ](pandas.read_stata.html)
    * [ pandas.DataFrame.to_stata ](pandas.DataFrame.to_stata.html)
    * [ pandas.io.stata.StataReader.data_label ](pandas.io.stata.StataReader.data_label.html)
    * [ pandas.io.stata.StataReader.value_labels ](pandas.io.stata.StataReader.value_labels.html)
    * [ pandas.io.stata.StataReader.variable_labels ](pandas.io.stata.StataReader.variable_labels.html)
    * [ pandas.io.stata.StataWriter.write_file ](pandas.io.stata.StataWriter.write_file.html)
  * [ General functions ](../general_functions.html)
  * [ Series ](../series.html)
  * [ DataFrame ](../frame.html)
  * [ pandas arrays, scalars, and data types ](../arrays.html)
  * [ Index objects ](../indexing.html)
  * [ Date offsets ](../offset_frequency.html)
  * [ Window ](../window.html)
  * [ GroupBy ](../groupby.html)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ Input/output ](../io.html)
  * pandas.DataF... 

#  pandas.DataFrame.to_pickle  #

DataFrame.  to_pickle  (  _ path  _ , _ *  _ , _ compression  =  'infer'  _ ,
_ protocol  =  5  _ , _ storage_options  =  None  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L3100-L3171) #

    

Pickle (serialize) object to file.

Parameters  :

    

**path** str, path object, or file-like object

    

String, path object (implementing ` os.PathLike[str]  ` ), or file-like object
implementing a binary ` write()  ` function. File path where the pickled
object will be stored.

**compression** str or dict, default âinferâ

    

For on-the-fly compression of the output data. If âinferâ and âpathâ
is path-like, then detect compression from the following extensions:
â.gzâ, â.bz2â, â.zipâ, â.xzâ, â.zstâ, â.tarâ,
â.tar.gzâ, â.tar.xzâ or â.tar.bz2â (otherwise no compression). Set
to ` None  ` for no compression. Can also be a dict with key ` 'method'  ` set
to one of { ` 'zip'  ` , ` 'gzip'  ` , ` 'bz2'  ` , ` 'zstd'  ` , ` 'xz'  ` ,
` 'tar'  ` } and other key-value pairs are forwarded to ` zipfile.ZipFile  ` ,
` gzip.GzipFile  ` , ` bz2.BZ2File  ` , ` zstandard.ZstdCompressor  ` , `
lzma.LZMAFile  ` or ` tarfile.TarFile  ` , respectively. As an example, the
following could be passed for faster compression and to create a reproducible
gzip archive: ` compression={'method':  'gzip',  'compresslevel':  1,
'mtime':  1}  ` .

New in version 1.5.0:  Added support for  .tar  files.

**protocol** int

    

Int which indicates which protocol should be used by the pickler, default
HIGHEST_PROTOCOL (see  [1]  paragraph 12.1.2). The possible values are 0, 1,
2, 3, 4, 5. A negative value for the protocol parameter is equivalent to
setting its value to HIGHEST_PROTOCOL.

[  1  ]

[ https://docs.python.org/3/library/pickle.html
](https://docs.python.org/3/library/pickle.html) .

**storage_options** dict, optional

    

Extra options that make sense for a particular storage connection, e.g. host,
port, username, password, etc. For HTTP(S) URLs the key-value pairs are
forwarded to ` urllib.request.Request  ` as header options. For other URLs
(e.g. starting with âs3://â, and âgcs://â) the key-value pairs are
forwarded to ` fsspec.open  ` . Please see ` fsspec  ` and ` urllib  ` for
more details, and for more examples on storage options refer [ here
](https://pandas.pydata.org/docs/user_guide/io.html?highlight=storage_options#reading-
writing-remote-files) .

See also

[ ` read_pickle  ` ](pandas.read_pickle.html#pandas.read_pickle
"pandas.read_pickle")

    

Load pickled pandas object (or any object) from file.

[ ` DataFrame.to_hdf  ` ](pandas.DataF