From a5f5954fe540eb9ffcf8378b287008aa9bf08237 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Sat, 26 Aug 2023 14:15:04 +0200 Subject: [PATCH 1/2] add dataframe.join --- .../dataframe_api/dataframe_object.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index cd109a7e..c7d4826a 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -897,3 +897,45 @@ def to_array_object(self, dtype: Any) -> Any: understanding that consuming libraries would then use the ``array-api-compat`` package to convert it to a Standard-compliant array. """ + + def join( + self, + other: DataFrame, + *, + how: Literal['left', 'inner', 'outer'], + on: str | list[str] | None = None, + left_on: str | list[str] | None = None, + right_on: str | list[str] | None = None, + ) -> DataFrame: + """ + Join with other dataframe. + + Parameters + ---------- + other : DataFrame + Dataframe to join with. + how : str + Kind of join to perform. + Must be one of {'left', 'inner', 'outer'}. + on : str | list[str], optional + Key(s) to use to perform join. + Cannot be used in conjunction with `left_on` or `right_on`. + left_on : str | list[str], optional + Key(s) from `self` to perform `join` on. + If more than one key is given, it must be + the same length as `right_on`. + Cannot be used in conjunction with `on`. + right_on : str | list[str], optional + Key(s) from `other` to perform `join` on. + If more than one key is given, it must be + the same length as `left_on`. + Cannot be used in conjunction with `on`. + + Returns + ------- + DataFrame + + Notes + ----- + Either `on`, or both `left_on` and `right_on`, must be specified. + """ From 2978c33eac21afef3cf8ab0e6bb06f8775fd2298 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:24:10 +0200 Subject: [PATCH 2/2] remove on --- .../dataframe_api/dataframe_object.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index c7d4826a..f1881328 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -903,9 +903,8 @@ def join( other: DataFrame, *, how: Literal['left', 'inner', 'outer'], - on: str | list[str] | None = None, - left_on: str | list[str] | None = None, - right_on: str | list[str] | None = None, + left_on: str | list[str], + right_on: str | list[str], ) -> DataFrame: """ Join with other dataframe. @@ -917,25 +916,16 @@ def join( how : str Kind of join to perform. Must be one of {'left', 'inner', 'outer'}. - on : str | list[str], optional - Key(s) to use to perform join. - Cannot be used in conjunction with `left_on` or `right_on`. - left_on : str | list[str], optional + left_on : str | list[str] Key(s) from `self` to perform `join` on. If more than one key is given, it must be the same length as `right_on`. - Cannot be used in conjunction with `on`. - right_on : str | list[str], optional + right_on : str | list[str] Key(s) from `other` to perform `join` on. If more than one key is given, it must be the same length as `left_on`. - Cannot be used in conjunction with `on`. Returns ------- DataFrame - - Notes - ----- - Either `on`, or both `left_on` and `right_on`, must be specified. """