From 46eb08ec24e615dcb467095af16829107afaaf70 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <> Date: Mon, 17 Apr 2023 08:54:35 +0100 Subject: [PATCH 01/12] draft concat --- .../dataframe_api/dataframe_object.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index c133d79a..d42e0f48 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -214,6 +214,22 @@ def get_column_names(self) -> Sequence[str]: """ ... + def concat(self, other: Sequence[DataFrame]) -> DataFrame: + """ + Concatenate current and other DataFrames vertically. + + To concatenate horizontally, please use ``insert``. + + Parameters + ---------- + other : Sequence[DataFrame] + DataFrames to concatenate with. + + Returns + ------- + DataFrame + """ + def __eq__(self, other: DataFrame | Scalar) -> DataFrame: """ Compare for equality. From fa16046db7d0c1e888c1b30ffaddb678fccf9f8d Mon Sep 17 00:00:00 2001 From: MarcoGorelli <> Date: Mon, 17 Apr 2023 18:08:42 +0100 Subject: [PATCH 02/12] note about strictness --- spec/API_specification/dataframe_api/dataframe_object.py | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index d42e0f48..05a82047 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -224,6 +224,7 @@ def concat(self, other: Sequence[DataFrame]) -> DataFrame: ---------- other : Sequence[DataFrame] DataFrames to concatenate with. + Column names, ordering, and dtypes must match. Returns ------- From e9ef9371098daae32914d67861c921ed8c5887f3 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <> Date: Wed, 26 Apr 2023 15:46:32 +0100 Subject: [PATCH 03/12] note ordering --- spec/API_specification/dataframe_api/dataframe_object.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index 05a82047..6e3f5f80 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -226,6 +226,11 @@ def concat(self, other: Sequence[DataFrame]) -> DataFrame: DataFrames to concatenate with. Column names, ordering, and dtypes must match. + Notes + ----- + The order in which the input DataFrames appear in + the output is not guaranteed and may vary across implementations. + Returns ------- DataFrame From d323908c9f5a026fd02c46f344a9dda38e7bbe4b Mon Sep 17 00:00:00 2001 From: MarcoGorelli <> Date: Thu, 27 Apr 2023 12:09:14 +0100 Subject: [PATCH 04/12] note that order is indeed preservedd --- spec/API_specification/dataframe_api/dataframe_object.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index 6e0a7792..9639435d 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -254,7 +254,7 @@ def concat(self, other: Sequence[DataFrame]) -> DataFrame: Notes ----- The order in which the input DataFrames appear in - the output is not guaranteed and may vary across implementations. + the output is preserved. Returns ------- From ce6860519f1ca7567dcc58aab3dbabce0b36af58 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <> Date: Thu, 27 Apr 2023 12:13:35 +0100 Subject: [PATCH 05/12] lint --- spec/API_specification/dataframe_api/dataframe_object.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index a463b336..d2d9df3d 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -288,7 +288,8 @@ def sorted_indices( If a sequence, it must be the same length as `keys`, and determines the direction with which to use each key to sort by. - nulls_position : {'first', 'last'} + nulls_position : str + Can be either `'first'` or `'last'`. Whether null values should be placed at the beginning or at the end of the result. Note that the position of NaNs is unspecified and may From eed4ef4d9f790f2c9c816e98ecd13c67bcd5e3bf Mon Sep 17 00:00:00 2001 From: MarcoGorelli <> Date: Thu, 27 Apr 2023 12:29:15 +0100 Subject: [PATCH 06/12] fixup first/last rendering --- spec/API_specification/dataframe_api/dataframe_object.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index d2d9df3d..2cfa1c31 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -288,8 +288,7 @@ def sorted_indices( If a sequence, it must be the same length as `keys`, and determines the direction with which to use each key to sort by. - nulls_position : str - Can be either `'first'` or `'last'`. + nulls_position : ``{'first', 'last'}`` Whether null values should be placed at the beginning or at the end of the result. Note that the position of NaNs is unspecified and may From 0277fcca93c49e29de53a9f3a249ace4a1cb689f Mon Sep 17 00:00:00 2001 From: MarcoGorelli <> Date: Fri, 28 Apr 2023 17:35:14 +0100 Subject: [PATCH 07/12] move concat to __init__ --- .../dataframe_api/__init__.py | 24 +++++++++++++++++++ .../dataframe_api/dataframe_object.py | 23 ------------------ 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index 94462b17..e0ec8534 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -1,6 +1,7 @@ """ Function stubs and API documentation for the DataFrame API standard. """ +from typing import Sequence from .column_object import * from .dataframe_object import * @@ -12,3 +13,26 @@ String representing the version of the DataFrame API specification to which the conforming implementation adheres. """ + +def concat(dataframes: Sequence[DataFrame]) -> DataFrame: + """ + Concatenate DataFrames vertically. + + To concatenate horizontally, please use ``insert``. + + Parameters + ---------- + dataframes : Sequence[DataFrame] + DataFrames to concatenate. + Column names, ordering, and dtypes must match. + + Notes + ----- + The order in which the input DataFrames appear in + the output is preserved. + + Returns + ------- + DataFrame + """ + ... diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index 2cfa1c31..8139d09d 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -241,29 +241,6 @@ def get_column_names(self) -> Sequence[str]: """ ... - def concat(self, other: Sequence[DataFrame]) -> DataFrame: - """ - Concatenate current and other DataFrames vertically. - - To concatenate horizontally, please use ``insert``. - - Parameters - ---------- - other : Sequence[DataFrame] - DataFrames to concatenate with. - Column names, ordering, and dtypes must match. - - Notes - ----- - The order in which the input DataFrames appear in - the output is preserved. - - Returns - ------- - DataFrame - """ - ... - def sorted_indices( self, keys: Sequence[str], From 2827cd646df0d9f97abbce31d26cbbd3a18b0af3 Mon Sep 17 00:00:00 2001 From: Marco Edward Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Tue, 2 May 2023 17:51:46 +0100 Subject: [PATCH 08/12] Update spec/API_specification/dataframe_api/dataframe_object.py --- spec/API_specification/dataframe_api/dataframe_object.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index 8139d09d..e7c12cd3 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -265,7 +265,7 @@ def sorted_indices( If a sequence, it must be the same length as `keys`, and determines the direction with which to use each key to sort by. - nulls_position : ``{'first', 'last'}`` + nulls_position : {'first', 'last'} Whether null values should be placed at the beginning or at the end of the result. Note that the position of NaNs is unspecified and may From 71bb209d6f789ab6fa9c76eccc181d66a42f9560 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <> Date: Tue, 2 May 2023 20:05:13 +0100 Subject: [PATCH 09/12] Revert "Update spec/API_specification/dataframe_api/dataframe_object.py" This reverts commit 2827cd646df0d9f97abbce31d26cbbd3a18b0af3. --- spec/API_specification/dataframe_api/dataframe_object.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index e7c12cd3..8139d09d 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -265,7 +265,7 @@ def sorted_indices( If a sequence, it must be the same length as `keys`, and determines the direction with which to use each key to sort by. - nulls_position : {'first', 'last'} + nulls_position : ``{'first', 'last'}`` Whether null values should be placed at the beginning or at the end of the result. Note that the position of NaNs is unspecified and may From dbbad7e44a1633b31ed6fc72aa9a40d7e657b0b2 Mon Sep 17 00:00:00 2001 From: Marco Edward Gorelli Date: Wed, 10 May 2023 14:29:11 +0200 Subject: [PATCH 10/12] Update spec/API_specification/dataframe_api/__init__.py --- spec/API_specification/dataframe_api/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index e0ec8534..8cbbea2b 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -29,7 +29,8 @@ def concat(dataframes: Sequence[DataFrame]) -> DataFrame: Notes ----- The order in which the input DataFrames appear in - the output is preserved. + the output is preserved (so long as the DataFrame implementation supports ordered + columns). Returns ------- From 3ba1a4bb79d286619ea8e8f63de2e85b16ad79b6 Mon Sep 17 00:00:00 2001 From: Marco Edward Gorelli Date: Thu, 11 May 2023 12:25:40 +0200 Subject: [PATCH 11/12] Update spec/API_specification/dataframe_api/__init__.py Co-authored-by: Keith Kraus --- spec/API_specification/dataframe_api/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index 8cbbea2b..eb2a22aa 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -29,8 +29,8 @@ def concat(dataframes: Sequence[DataFrame]) -> DataFrame: Notes ----- The order in which the input DataFrames appear in - the output is preserved (so long as the DataFrame implementation supports ordered - columns). + the output is preserved (so long as the DataFrame implementation supports row + ordering). Returns ------- From 869f8587db84c0e2caf56be089e0ddc936979408 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Mon, 15 May 2023 15:59:04 +0100 Subject: [PATCH 12/12] post-merge fixup --- spec/API_specification/dataframe_api/__init__.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index 831c3ab6..c8d2fc76 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -1,13 +1,9 @@ """ Function stubs and API documentation for the DataFrame API standard. """ -<<<<<<< HEAD -from typing import Sequence -======= from __future__ import annotations from typing import Mapping, Sequence ->>>>>>> upstream/main from .column_object import * from .dataframe_object import *