From 565ca623d2c3736e03954e912c7d74db85daedf1 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Thu, 26 Oct 2023 08:52:12 +0100 Subject: [PATCH 1/3] remove `names` from dataframe_from_2d_array --- spec/API_specification/dataframe_api/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index 74dc4346..5f90ba19 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -135,7 +135,7 @@ def column_from_1d_array(array: Any, *, dtype: DType, name: str = '') -> Column: """ ... -def dataframe_from_2d_array(array: Any, *, names: Sequence[str], dtypes: Mapping[str, Any]) -> DataFrame: +def dataframe_from_2d_array(array: Any, *, dtypes: Mapping[str, Any]) -> DataFrame: """ Construct DataFrame from 2D array. @@ -149,10 +149,9 @@ def dataframe_from_2d_array(array: Any, *, names: Sequence[str], dtypes: Mapping ---------- array : array array-API compliant 2D array - names : Sequence[str] - Names to give columns. Must be the same length as ``array.shape[1]``. dtypes : Mapping[str, DType] Dtype of each column. Must be the same length as ``array.shape[1]``. + Keys determine column names. Returns ------- From 21e0000cd138315f6af58f53ca4222054fc9f67a Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Fri, 27 Oct 2023 09:56:24 +0100 Subject: [PATCH 2/3] Mapping -> Dict --- spec/API_specification/dataframe_api/__init__.py | 7 ++++--- spec/API_specification/dataframe_api/column_object.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index c5084296..8e897116 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -4,7 +4,7 @@ """ from __future__ import annotations -from typing import Mapping, Sequence, Any, Literal, TYPE_CHECKING +from typing import Dict, Sequence, Any, TYPE_CHECKING from .column_object import * from .dataframe_object import DataFrame @@ -137,7 +137,7 @@ def column_from_1d_array(array: Any, *, dtype: DType, name: str = '') -> Column: """ ... -def dataframe_from_2d_array(array: Any, *, dtypes: Mapping[str, Any]) -> DataFrame: +def dataframe_from_2d_array(array: Any, *, dtypes: Dict[str, Any]) -> DataFrame: """ Construct DataFrame from 2D array. @@ -203,8 +203,8 @@ def is_null(value: object, /) -> bool: bool True if the input is a `null` object from the same library which implements the dataframe API standard, False otherwise. - """ + ... def is_dtype(dtype: DType, kind: str | tuple[str, ...]) -> bool: """ @@ -236,6 +236,7 @@ def is_dtype(dtype: DType, kind: str | tuple[str, ...]) -> bool: ------- bool """ + ... def date(year: int, month: int, day: int) -> Scalar: """ diff --git a/spec/API_specification/dataframe_api/column_object.py b/spec/API_specification/dataframe_api/column_object.py index 638381eb..0bccf2d0 100644 --- a/spec/API_specification/dataframe_api/column_object.py +++ b/spec/API_specification/dataframe_api/column_object.py @@ -47,6 +47,7 @@ def column(self) -> Any: @property def name(self) -> str: """Return name of column.""" + ... def __len__(self) -> int: """ From 5ffb5d18eba7abe18c5544c1af409d0f301772a5 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Fri, 27 Oct 2023 15:36:07 +0100 Subject: [PATCH 3/3] rename to schema --- spec/API_specification/dataframe_api/__init__.py | 2 +- spec/API_specification/dataframe_api/typing.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index 8e897116..06aab09c 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -137,7 +137,7 @@ def column_from_1d_array(array: Any, *, dtype: DType, name: str = '') -> Column: """ ... -def dataframe_from_2d_array(array: Any, *, dtypes: Dict[str, Any]) -> DataFrame: +def dataframe_from_2d_array(array: Any, *, schema: Dict[str, DType]) -> DataFrame: """ Construct DataFrame from 2D array. diff --git a/spec/API_specification/dataframe_api/typing.py b/spec/API_specification/dataframe_api/typing.py index 1532b203..cf00591c 100644 --- a/spec/API_specification/dataframe_api/typing.py +++ b/spec/API_specification/dataframe_api/typing.py @@ -121,7 +121,7 @@ def column_from_sequence( self, sequence: Sequence[Any], *, - dtype: Any, + dtype: DType, name: str = "", ) -> Column: ... @@ -130,7 +130,7 @@ def dataframe_from_columns(self, *columns: Column) -> DataFrame: ... def column_from_1d_array( - self, array: Any, *, dtype: Any, name: str = "" + self, array: Any, *, dtype: DType, name: str = "" ) -> Column: ... @@ -139,14 +139,14 @@ def dataframe_from_2d_array( array: Any, *, names: Sequence[str], - dtypes: Mapping[str, Any], + schema: Mapping[str, DType], ) -> DataFrame: ... def is_null(self, value: object, /) -> bool: ... - def is_dtype(self, dtype: Any, kind: str | tuple[str, ...]) -> bool: + def is_dtype(self, dtype: DType, kind: str | tuple[str, ...]) -> bool: ... def date(self, year: int, month: int, day: int) -> Scalar: