Skip to content

Commit 76de473

Browse files
authored
REF: Rename exchange -> interchange (#47888)
1 parent 62a69be commit 76de473

18 files changed

+35
-35
lines changed

doc/source/reference/general_functions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ Importing from other DataFrame libraries
8585
.. autosummary::
8686
:toctree: api/
8787

88-
api.exchange.from_dataframe
88+
api.interchange.from_dataframe

pandas/api/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
""" public toolkit API """
22
from pandas.api import (
3-
exchange,
43
extensions,
54
indexers,
5+
interchange,
66
types,
77
)
88

99
__all__ = [
10-
"exchange",
10+
"interchange",
1111
"extensions",
1212
"indexers",
1313
"types",

pandas/api/exchange/__init__.py

-8
This file was deleted.

pandas/api/interchange/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
Public API for DataFrame interchange protocol.
3+
"""
4+
5+
from pandas.core.interchange.dataframe_protocol import DataFrame
6+
from pandas.core.interchange.from_dataframe import from_dataframe
7+
8+
__all__ = ["from_dataframe", "DataFrame"]

pandas/core/frame.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@
220220

221221
if TYPE_CHECKING:
222222

223-
from pandas.core.exchange.dataframe_protocol import DataFrame as DataFrameXchg
224223
from pandas.core.groupby.generic import DataFrameGroupBy
224+
from pandas.core.interchange.dataframe_protocol import DataFrame as DataFrameXchg
225225
from pandas.core.internals import SingleDataManager
226226
from pandas.core.resample import Resampler
227227

@@ -819,7 +819,7 @@ def __dataframe__(
819819
self, nan_as_null: bool = False, allow_copy: bool = True
820820
) -> DataFrameXchg:
821821
"""
822-
Return the dataframe exchange object implementing the exchange protocol.
822+
Return the dataframe interchange object implementing the interchange protocol.
823823
824824
Parameters
825825
----------
@@ -832,19 +832,19 @@ def __dataframe__(
832832
833833
Returns
834834
-------
835-
DataFrame exchange object
835+
DataFrame interchange object
836836
The object which consuming library can use to ingress the dataframe.
837837
838838
Notes
839839
-----
840-
Details on the exchange protocol:
840+
Details on the interchange protocol:
841841
https://data-apis.org/dataframe-protocol/latest/index.html
842842
843843
`nan_as_null` currently has no effect; once support for nullable extension
844844
dtypes is added, this value should be propagated to columns.
845845
"""
846846

847-
from pandas.core.exchange.dataframe import PandasDataFrameXchg
847+
from pandas.core.interchange.dataframe import PandasDataFrameXchg
848848

849849
return PandasDataFrameXchg(self, nan_as_null, allow_copy)
850850

pandas/core/exchange/buffer.py renamed to pandas/core/interchange/buffer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44
from packaging import version
55

6-
from pandas.core.exchange.dataframe_protocol import (
6+
from pandas.core.interchange.dataframe_protocol import (
77
Buffer,
88
DlpackDeviceType,
99
)

pandas/core/exchange/column.py renamed to pandas/core/interchange/column.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
is_categorical_dtype,
1313
is_string_dtype,
1414
)
15-
from pandas.core.exchange.buffer import PandasBuffer
16-
from pandas.core.exchange.dataframe_protocol import (
15+
from pandas.core.interchange.buffer import PandasBuffer
16+
from pandas.core.interchange.dataframe_protocol import (
1717
Column,
1818
ColumnBuffers,
1919
ColumnNullType,
2020
DtypeKind,
2121
)
22-
from pandas.core.exchange.utils import (
22+
from pandas.core.interchange.utils import (
2323
ArrowCTypes,
2424
Endianness,
2525
NoBufferPresent,
@@ -136,7 +136,7 @@ def _dtype_from_pandasdtype(self, dtype) -> tuple[DtypeKind, int, str, str]:
136136
kind = _NP_KINDS.get(dtype.kind, None)
137137
if kind is None:
138138
# Not a NumPy dtype. Check if it's a categorical maybe
139-
raise ValueError(f"Data type {dtype} not supported by exchange protocol")
139+
raise ValueError(f"Data type {dtype} not supported by interchange protocol")
140140

141141
return kind, dtype.itemsize * 8, dtype_to_arrow_c_fmt(dtype), dtype.byteorder
142142

pandas/core/exchange/dataframe.py renamed to pandas/core/interchange/dataframe.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from typing import TYPE_CHECKING
55

66
import pandas as pd
7-
from pandas.core.exchange.column import PandasColumn
8-
from pandas.core.exchange.dataframe_protocol import DataFrame as DataFrameXchg
7+
from pandas.core.interchange.column import PandasColumn
8+
from pandas.core.interchange.dataframe_protocol import DataFrame as DataFrameXchg
99

1010
if TYPE_CHECKING:
1111
from pandas import Index

pandas/core/exchange/dataframe_protocol.py renamed to pandas/core/interchange/dataframe_protocol.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ class DataFrame(ABC):
389389

390390
@abstractmethod
391391
def __dataframe__(self, nan_as_null: bool = False, allow_copy: bool = True):
392-
"""Construct a new exchange object, potentially changing the parameters."""
392+
"""Construct a new interchange object, potentially changing the parameters."""
393393
pass
394394

395395
@property

pandas/core/exchange/from_dataframe.py renamed to pandas/core/interchange/from_dataframe.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
import numpy as np
88

99
import pandas as pd
10-
from pandas.core.exchange.dataframe_protocol import (
10+
from pandas.core.interchange.dataframe_protocol import (
1111
Buffer,
1212
Column,
1313
ColumnNullType,
1414
DataFrame as DataFrameXchg,
1515
DtypeKind,
1616
)
17-
from pandas.core.exchange.utils import (
17+
from pandas.core.interchange.utils import (
1818
ArrowCTypes,
1919
Endianness,
2020
)
@@ -34,7 +34,7 @@ def from_dataframe(df, allow_copy=True) -> pd.DataFrame:
3434
Parameters
3535
----------
3636
df : DataFrameXchg
37-
Object supporting the exchange protocol, i.e. `__dataframe__` method.
37+
Object supporting the interchange protocol, i.e. `__dataframe__` method.
3838
allow_copy : bool, default: True
3939
Whether to allow copying the memory to perform the conversion
4040
(if false then zero-copy approach is requested).
@@ -54,12 +54,12 @@ def from_dataframe(df, allow_copy=True) -> pd.DataFrame:
5454

5555
def _from_dataframe(df: DataFrameXchg, allow_copy=True):
5656
"""
57-
Build a ``pd.DataFrame`` from the DataFrame exchange object.
57+
Build a ``pd.DataFrame`` from the DataFrame interchange object.
5858
5959
Parameters
6060
----------
6161
df : DataFrameXchg
62-
Object supporting the exchange protocol, i.e. `__dataframe__` method.
62+
Object supporting the interchange protocol, i.e. `__dataframe__` method.
6363
allow_copy : bool, default: True
6464
Whether to allow copying the memory to perform the conversion
6565
(if false then zero-copy approach is requested).
@@ -91,7 +91,7 @@ def _from_dataframe(df: DataFrameXchg, allow_copy=True):
9191

9292
def protocol_df_chunk_to_pandas(df: DataFrameXchg) -> pd.DataFrame:
9393
"""
94-
Convert exchange protocol chunk to ``pd.DataFrame``.
94+
Convert interchange protocol chunk to ``pd.DataFrame``.
9595
9696
Parameters
9797
----------

pandas/core/exchange/utils.py renamed to pandas/core/interchange/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Utility functions and objects for implementing the exchange API.
2+
Utility functions and objects for implementing the interchange API.
33
"""
44

55
from __future__ import annotations

pandas/tests/api/test_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def test_np():
277277

278278

279279
class TestApi(Base):
280-
allowed = ["types", "extensions", "indexers", "exchange"]
280+
allowed = ["types", "extensions", "indexers", "interchange"]
281281

282282
def test_api(self):
283283
self.check(api, self.allowed)

pandas/tests/exchange/test_impl.py renamed to pandas/tests/interchange/test_impl.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
import pandas as pd
88
import pandas._testing as tm
9-
from pandas.core.exchange.dataframe_protocol import (
9+
from pandas.core.interchange.dataframe_protocol import (
1010
ColumnNullType,
1111
DtypeKind,
1212
)
13-
from pandas.core.exchange.from_dataframe import from_dataframe
13+
from pandas.core.interchange.from_dataframe import from_dataframe
1414

1515
test_data_categorical = {
1616
"ordered": pd.Categorical(list("testdata") * 30, ordered=True),

pandas/tests/exchange/test_utils.py renamed to pandas/tests/interchange/test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33

44
import pandas as pd
5-
from pandas.core.exchange.utils import dtype_to_arrow_c_fmt
5+
from pandas.core.interchange.utils import dtype_to_arrow_c_fmt
66

77
# TODO: use ArrowSchema to get reference C-string.
88
# At the time, there is no way to access ArrowSchema holding a type format string

0 commit comments

Comments
 (0)