diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index 94462b17..df239329 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -1,14 +1,54 @@ """ Function stubs and API documentation for the DataFrame API standard. """ +from __future__ import annotations + +from typing import Mapping, Sequence from .column_object import * from .dataframe_object import * from .groupby_object import * +from ._types import dtype + __dataframe_api_version__: str = "YYYY.MM" """ String representing the version of the DataFrame API specification to which the conforming implementation adheres. """ + +def column_from_sequence(sequence: Sequence[object], *, dtype: dtype) -> Column: + """ + Construct Column from sequence of elements. + + Parameters + ---------- + sequence : Sequence[object] + Sequence of elements. Each element must be of the specified + ``dtype``, the corresponding Python builtin scalar type, or + coercible to that Python scalar type. + dtype : str + Dtype of result. Must be specified. + + Returns + ------- + Column + """ + ... + +def dataframe_from_dict(data: Mapping[str, Column]) -> DataFrame: + """ + Construct DataFrame from map of column names to Columns. + + Parameters + ---------- + data : Mapping[str, Column] + Column must be of the corresponding type of the DataFrame. + For example, it is only supported to build a ``LibraryXDataFrame`` using + ``LibraryXColumn`` instances. + + Returns + ------- + DataFrame + """ diff --git a/spec/API_specification/dataframe_api/column_object.py b/spec/API_specification/dataframe_api/column_object.py index e402cbf6..6bc7e682 100644 --- a/spec/API_specification/dataframe_api/column_object.py +++ b/spec/API_specification/dataframe_api/column_object.py @@ -17,26 +17,6 @@ class Column: constructor functions or an already-created dataframe object retrieved via """ - @classmethod - def from_sequence(cls, sequence: Sequence[object], dtype: dtype) -> Column: - """ - Construct Column from sequence of elements. - - Parameters - ---------- - sequence : Sequence[object] - Sequence of elements. Each element must be of the specified - ``dtype``, the corresponding Python builtin scalar type, or - coercible to that Python scalar type. - dtype : str - Dtype of result. Must be specified. - - Returns - ------- - Column - """ - ... - def __len__(self) -> int: """ Return the number of rows.