Skip to content

Add api_version to constructors #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions spec/API_specification/dataframe_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def concat(dataframes: Sequence[DataFrame]) -> DataFrame:
"""
...

def column_from_sequence(sequence: Sequence[Any], *, dtype: Any, name: str = '') -> Column[Any]:
def column_from_sequence(sequence: Sequence[Any], *, dtype: Any, name: str = '', api_version: str | None = None) -> Column[Any]:
"""
Construct Column from sequence of elements.

Expand All @@ -77,14 +77,21 @@ def column_from_sequence(sequence: Sequence[Any], *, dtype: Any, name: str = '')
Name of column.
dtype : DType
Dtype of result. Must be specified.
api_version: str | None
A string representing the version of the dataframe API specification
in ``'YYYY.MM'`` form, for example, ``'2023.04'``.
If it is ``None``, it should return an object corresponding to
latest version of the dataframe API specification. If the given
version is invalid or not implemented for the given module, an
error should be raised. Default: ``None``.

Returns
-------
Column
"""
...

def dataframe_from_dict(data: Mapping[str, Column[Any]]) -> DataFrame:
def dataframe_from_dict(data: Mapping[str, Column[Any]], *, api_version: str | None = None) -> DataFrame:
"""
Construct DataFrame from map of column names to Columns.

Expand All @@ -94,6 +101,13 @@ def dataframe_from_dict(data: Mapping[str, Column[Any]]) -> DataFrame:
Column must be of the corresponding type of the DataFrame.
For example, it is only supported to build a ``LibraryXDataFrame`` using
``LibraryXColumn`` instances.
api_version: str | None
A string representing the version of the dataframe API specification
in ``'YYYY.MM'`` form, for example, ``'2023.04'``.
If it is ``None``, it should return an object corresponding to
latest version of the dataframe API specification. If the given
version is invalid or not implemented for the given module, an
error should be raised. Default: ``None``.

Returns
-------
Expand All @@ -109,7 +123,7 @@ def dataframe_from_dict(data: Mapping[str, Column[Any]]) -> DataFrame:
...


def column_from_1d_array(array: Any, *, dtype: Any, name: str = '') -> Column[Any]:
def column_from_1d_array(array: Any, *, dtype: Any, name: str = '', api_version: str | None = None) -> Column[Any]:
"""
Construct Column from 1D array.

Expand All @@ -127,14 +141,21 @@ def column_from_1d_array(array: Any, *, dtype: Any, name: str = '') -> Column[An
Name to give columns.
dtype : DType
Dtype of column.
api_version: str | None
A string representing the version of the dataframe API specification
in ``'YYYY.MM'`` form, for example, ``'2023.04'``.
If it is ``None``, it should return an object corresponding to
latest version of the dataframe API specification. If the given
version is invalid or not implemented for the given module, an
error should be raised. Default: ``None``.

Returns
-------
Column
"""
...

def dataframe_from_2d_array(array: Any, *, names: Sequence[str], dtypes: Mapping[str, Any]) -> DataFrame:
def dataframe_from_2d_array(array: Any, *, names: Sequence[str], dtypes: Mapping[str, Any], api_version: str | None = None) -> DataFrame:
"""
Construct DataFrame from 2D array.

Expand All @@ -152,6 +173,13 @@ def dataframe_from_2d_array(array: Any, *, names: Sequence[str], dtypes: Mapping
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]``.
api_version: str | None
A string representing the version of the dataframe API specification
in ``'YYYY.MM'`` form, for example, ``'2023.04'``.
If it is ``None``, it should return an object corresponding to
latest version of the dataframe API specification. If the given
version is invalid or not implemented for the given module, an
error should be raised. Default: ``None``.

Returns
-------
Expand Down