save_feather¶
- pyhelpers.store.save_feather(data, path_to_file, index=True, verbose=False, raise_error=False, **kwargs)[source]¶
Saves a dataframe to a Feather file.
Note
The Feather format may require the index to be the default integer index. If the index is not a standard range, or if
index=True, it will be automatically reset and saved as a column.- Parameters:
data (pandas.DataFrame) – The dataframe to be saved.
path_to_file (str | pathlib.Path) – The path where the Feather file will be saved.
index (bool | None) – Whether to include the index as a column. If
None, the index is included only if it is not the default range; defaults toTrue.verbose (bool | int) – Whether to print relevant information to the console; defaults to
False.raise_error (bool) – Whether to raise an exception if saving fails; defaults to
False.kwargs – [Optional] Additional parameters for pandas.DataFrame.to_feather().
Examples:
>>> from pyhelpers.store import save_feather >>> from pyhelpers.dirs import cd >>> from pyhelpers._cache import example_dataframe >>> feather_dat = example_dataframe() # Get an example dataframe >>> feather_dat Longitude Latitude City London -0.127647 51.507322 Birmingham -1.902691 52.479699 Manchester -2.245115 53.479489 Leeds -1.543794 53.797418 >>> feather_pathname = cd("tests/data", "dat.feather") >>> save_feather(feather_dat, feather_pathname, verbose=True) Saving "dat.feather" to "./tests/data/" ... Done. >>> save_feather(feather_dat, feather_pathname, index=True, verbose=True) Updating "dat.feather" in "./tests/data/" ... Done.
See also
Examples for the function
pyhelpers.store.load_feather().