Skip to content

Commit b30416b

Browse files
authored
Add api_version to constructors (#233)
* add api versions to some constructors * namespace -> object * remove "to be returned,"
1 parent 91ec267 commit b30416b

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

spec/API_specification/dataframe_api/__init__.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def concat(dataframes: Sequence[DataFrame]) -> DataFrame:
6363
"""
6464
...
6565

66-
def column_from_sequence(sequence: Sequence[Any], *, dtype: Any, name: str = '') -> Column[Any]:
66+
def column_from_sequence(sequence: Sequence[Any], *, dtype: Any, name: str = '', api_version: str | None = None) -> Column[Any]:
6767
"""
6868
Construct Column from sequence of elements.
6969
@@ -77,14 +77,21 @@ def column_from_sequence(sequence: Sequence[Any], *, dtype: Any, name: str = '')
7777
Name of column.
7878
dtype : DType
7979
Dtype of result. Must be specified.
80+
api_version: str | None
81+
A string representing the version of the dataframe API specification
82+
in ``'YYYY.MM'`` form, for example, ``'2023.04'``.
83+
If it is ``None``, it should return an object corresponding to
84+
latest version of the dataframe API specification. If the given
85+
version is invalid or not implemented for the given module, an
86+
error should be raised. Default: ``None``.
8087
8188
Returns
8289
-------
8390
Column
8491
"""
8592
...
8693

87-
def dataframe_from_dict(data: Mapping[str, Column[Any]]) -> DataFrame:
94+
def dataframe_from_dict(data: Mapping[str, Column[Any]], *, api_version: str | None = None) -> DataFrame:
8895
"""
8996
Construct DataFrame from map of column names to Columns.
9097
@@ -94,6 +101,13 @@ def dataframe_from_dict(data: Mapping[str, Column[Any]]) -> DataFrame:
94101
Column must be of the corresponding type of the DataFrame.
95102
For example, it is only supported to build a ``LibraryXDataFrame`` using
96103
``LibraryXColumn`` instances.
104+
api_version: str | None
105+
A string representing the version of the dataframe API specification
106+
in ``'YYYY.MM'`` form, for example, ``'2023.04'``.
107+
If it is ``None``, it should return an object corresponding to
108+
latest version of the dataframe API specification. If the given
109+
version is invalid or not implemented for the given module, an
110+
error should be raised. Default: ``None``.
97111
98112
Returns
99113
-------
@@ -109,7 +123,7 @@ def dataframe_from_dict(data: Mapping[str, Column[Any]]) -> DataFrame:
109123
...
110124

111125

112-
def column_from_1d_array(array: Any, *, dtype: Any, name: str = '') -> Column[Any]:
126+
def column_from_1d_array(array: Any, *, dtype: Any, name: str = '', api_version: str | None = None) -> Column[Any]:
113127
"""
114128
Construct Column from 1D array.
115129
@@ -127,14 +141,21 @@ def column_from_1d_array(array: Any, *, dtype: Any, name: str = '') -> Column[An
127141
Name to give columns.
128142
dtype : DType
129143
Dtype of column.
144+
api_version: str | None
145+
A string representing the version of the dataframe API specification
146+
in ``'YYYY.MM'`` form, for example, ``'2023.04'``.
147+
If it is ``None``, it should return an object corresponding to
148+
latest version of the dataframe API specification. If the given
149+
version is invalid or not implemented for the given module, an
150+
error should be raised. Default: ``None``.
130151
131152
Returns
132153
-------
133154
Column
134155
"""
135156
...
136157

137-
def dataframe_from_2d_array(array: Any, *, names: Sequence[str], dtypes: Mapping[str, Any]) -> DataFrame:
158+
def dataframe_from_2d_array(array: Any, *, names: Sequence[str], dtypes: Mapping[str, Any], api_version: str | None = None) -> DataFrame:
138159
"""
139160
Construct DataFrame from 2D array.
140161
@@ -152,6 +173,13 @@ def dataframe_from_2d_array(array: Any, *, names: Sequence[str], dtypes: Mapping
152173
Names to give columns. Must be the same length as ``array.shape[1]``.
153174
dtypes : Mapping[str, DType]
154175
Dtype of each column. Must be the same length as ``array.shape[1]``.
176+
api_version: str | None
177+
A string representing the version of the dataframe API specification
178+
in ``'YYYY.MM'`` form, for example, ``'2023.04'``.
179+
If it is ``None``, it should return an object corresponding to
180+
latest version of the dataframe API specification. If the given
181+
version is invalid or not implemented for the given module, an
182+
error should be raised. Default: ``None``.
155183
156184
Returns
157185
-------

0 commit comments

Comments
 (0)