diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 42de85945cbcb..728ececd59f6c 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2524,6 +2524,17 @@ def to_msgpack(self, path_or_buf=None, encoding="utf-8", **kwargs): It is recommended to use pyarrow for on-the-wire transmission of pandas objects. + Example pyarrow usage: + + >>> import pandas as pd + >>> import pyarrow as pa + >>> df = pd.DataFrame({'A': [1, 2, 3]}) + >>> context = pa.default_serialization_context() + >>> df_bytestring = context.serialize(df).to_buffer().to_pybytes() + + For documentation on pyarrow, see `here + `__. + Parameters ---------- path : str, buffer-like, or None diff --git a/pandas/io/packers.py b/pandas/io/packers.py index ad47ba23b9221..0d3bd4b7d46b9 100644 --- a/pandas/io/packers.py +++ b/pandas/io/packers.py @@ -105,6 +105,17 @@ def to_msgpack(path_or_buf, *args, **kwargs): It is recommended to use pyarrow for on-the-wire transmission of pandas objects. + Example pyarrow usage: + + >>> import pandas as pd + >>> import pyarrow as pa + >>> df = pd.DataFrame({'A': [1, 2, 3]}) + >>> context = pa.default_serialization_context() + >>> df_bytestring = context.serialize(df).to_buffer().to_pybytes() + + For documentation on pyarrow, see `here + `__. + Parameters ---------- path_or_buf : string File path, buffer-like, or None @@ -120,7 +131,9 @@ def to_msgpack(path_or_buf, *args, **kwargs): "to_msgpack is deprecated and will be removed in a " "future version.\n" "It is recommended to use pyarrow for on-the-wire " - "transmission of pandas objects.", + "transmission of pandas objects.\n" + "For a full example, check\n" + "https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_msgpack.html", # noqa: E501 FutureWarning, stacklevel=3, )