This is an automated email from the ASF dual-hosted git repository.

raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new fe298b424f GH-49628: [Python][Interchange protocol] Suppress warnings 
for pandas 4.0.0 and update docs (#49630)
fe298b424f is described below

commit fe298b424f4c7e33cdc9331221ece9302f6abb26
Author: Alenka Frim <[email protected]>
AuthorDate: Tue Apr 7 11:02:15 2026 +0200

    GH-49628: [Python][Interchange protocol] Suppress warnings for pandas 4.0.0 
and update docs (#49630)
    
    ### Rationale for this change
    Pandas is moving the dataframe interchange protocol out of the repo in the 
next major release (4.0.0).
    
    ### What changes are included in this PR?
    Filterwarnings are added and the pandas example is removed from the 
interchange documentation.
    
    ### Are these changes tested?
    Yes, via CI.
    
    ### Are there any user-facing changes?
    No.
    
    * GitHub Issue: #49628
    
    Authored-by: AlenkaF <[email protected]>
    Signed-off-by: Raúl Cumplido <[email protected]>
---
 docs/source/python/interchange_protocol.rst        | 33 +++++-----------------
 python/pyarrow/interchange/from_dataframe.py       | 25 ----------------
 .../pyarrow/tests/interchange/test_conversion.py   |  4 +++
 3 files changed, 11 insertions(+), 51 deletions(-)

diff --git a/docs/source/python/interchange_protocol.rst 
b/docs/source/python/interchange_protocol.rst
index efb10d2ab5..a586a364ff 100644
--- a/docs/source/python/interchange_protocol.rst
+++ b/docs/source/python/interchange_protocol.rst
@@ -36,6 +36,12 @@ libraries in the Python ecosystem. See more about the
 standard in the
 `protocol documentation 
<https://data-apis.org/dataframe-protocol/latest/index.html>`_.
 
+.. note::
+
+   The recommended way to convert between dataframe libraries is through
+   the :ref:`arrow-pycapsule-interface`, for example by calling 
``pa.table(df)``
+   on a dataframe object that implements it.
+
 From PyArrow to other libraries: ``__dataframe__()`` method
 -----------------------------------------------------------
 
@@ -61,34 +67,9 @@ from any dataframe object that implements the
 ``__dataframe__()`` method via the dataframe interchange
 protocol.
 
-We can for example take a pandas dataframe and construct a
+We can for example take a polars dataframe and construct a
 PyArrow table with the use of the interchange protocol:
 
-.. code-block:: python
-
-    >>> import pyarrow
-    >>> from pyarrow.interchange import from_dataframe
-
-    >>> import pandas as pd
-    >>> df = pd.DataFrame({
-    ...         "n_attendees": [100, 10, 1],
-    ...         "country": ["Italy", "Spain", "Slovenia"],
-    ...     })
-    >>> df
-       n_attendees   country
-    0          100     Italy
-    1           10     Spain
-    2            1  Slovenia
-    >>> from_dataframe(df)
-    pyarrow.Table
-    n_attendees: int64
-    country: large_string
-    ----
-    n_attendees: [[100,10,1]]
-    country: [["Italy","Spain","Slovenia"]]
-
-We can do the same with a polars dataframe:
-
 .. code-block:: python
 
     >>> import polars as pl  # doctest: +SKIP
diff --git a/python/pyarrow/interchange/from_dataframe.py 
b/python/pyarrow/interchange/from_dataframe.py
index fcaec41e3d..fc6530a833 100644
--- a/python/pyarrow/interchange/from_dataframe.py
+++ b/python/pyarrow/interchange/from_dataframe.py
@@ -76,31 +76,6 @@ def from_dataframe(df: DataFrameObject, allow_copy=True) -> 
pa.Table:
     Returns
     -------
     pa.Table
-
-    Examples
-    --------
-    >>> import pyarrow
-    >>> from pyarrow.interchange import from_dataframe
-
-    Convert a pandas dataframe to a pyarrow table:
-
-    >>> import pandas as pd
-    >>> df = pd.DataFrame({
-    ...         "n_attendees": [100, 10, 1],
-    ...         "country": ["Italy", "Spain", "Slovenia"],
-    ...     })
-    >>> df
-       n_attendees   country
-    0          100     Italy
-    1           10     Spain
-    2            1  Slovenia
-    >>> from_dataframe(df)
-    pyarrow.Table
-    n_attendees: int64
-    country: large_string
-    ----
-    n_attendees: [[100,10,1]]
-    country: [["Italy","Spain","Slovenia"]]
     """
     if isinstance(df, pa.Table):
         return df
diff --git a/python/pyarrow/tests/interchange/test_conversion.py 
b/python/pyarrow/tests/interchange/test_conversion.py
index 50da6693af..81713b94e6 100644
--- a/python/pyarrow/tests/interchange/test_conversion.py
+++ b/python/pyarrow/tests/interchange/test_conversion.py
@@ -40,6 +40,10 @@ except ImportError:
     pass
 
 
+pytestmark = pytest.mark.filterwarnings(
+    "ignore:The Dataframe Interchange Protocol is deprecated.")
+
+
 @pytest.mark.parametrize("unit", ['s', 'ms', 'us', 'ns'])
 @pytest.mark.parametrize("tz", ['', 'America/New_York', '+07:30', '-04:30'])
 def test_datetime(unit, tz):

Reply via email to