save_pickle¶
- pyhelpers.store.save_pickle(data, path_to_file, verbose=False, **kwargs)[source]¶
Save data to a Pickle file.
- Parameters:
data (Any) – Data to be saved, compatible with the built-in pickle.dump() function.
path_to_file (str | os.PathLike) – Path where the Pickle file will be saved.
verbose (bool | int) – Whether to print relevant information to the console; defaults to
False
.kwargs – [Optional] Additional parameters for pickle.dump().
Examples:
>>> from pyhelpers.store import save_pickle >>> from pyhelpers.dirs import cd >>> from pyhelpers._cache import example_dataframe >>> pickle_dat = 1 >>> pickle_pathname = cd("tests\data", "dat.pickle") >>> save_pickle(pickle_dat, pickle_pathname, verbose=True) Saving "dat.pickle" to "tests\data\" ... Done. >>> # Get an example dataframe >>> pickle_dat = example_dataframe() >>> pickle_dat Longitude Latitude City London -0.127647 51.507322 Birmingham -1.902691 52.479699 Manchester -2.245115 53.479489 Leeds -1.543794 53.797418 >>> save_pickle(pickle_dat, pickle_pathname, verbose=True) Updating "dat.pickle" at "tests\data\" ... Done.
See also
Examples for the function
load_pickle()
.