w3resource

Pandas DataFrame: to_pickle() function

DataFrame - to_pickle() function

The to_pickle() function is used to pickle (serialize) object to file.

Syntax:

DataFrame.to_pickle(self, path, compression='infer', protocol=4)

Parameters:

Name Description Type/Default Value Required / Optional
path  File path where the pickled object will be stored. str Required
compression   A string representing the compression to use in the output file. By default, infers from the file extension in specified path.  {'infer', 'gzip', 'bz2', 'zip', 'xz', None}
Default Value: 'infer'
Required
protocol Int which indicates which protocol should be used by the pickler, default HIGHEST_PROTOCOL  int Required

Example:


Download the Pandas DataFrame Notebooks from here.

Previous: DataFrame - to_parquet() function
Next: DataFrame - to_csv() function



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/pandas/dataframe/dataframe-to_pickle.php