October 2019
Beginner to intermediate
674 pages
16h 43m
English
When a Python object is pickled, it gets saved to disk. Pickling serializes the object first, before writing it. It involves converting objects such as lists, Dicts, DataFrames, and trained machine learning models into a character stream.
Let's convert the DataFrame we defined earlier into pickle format:
df.to_pickle('pickle_filename.pkl')
It is also possible to compress pickle files before they are written. Compression schemes such as gzip, bz2, and xz are supported:
df.to_pickle("pickle_filename.compress", compression="gzip")
By default, the compression type is inferred from the extension that's provided:
df.to_pickle("pickle_filename.gz")
The read_pickle() function will deserialize the pickle file. Zip compression is only ...
Read now
Unlock full access