Skip to content

Commit caf0689

Browse files
authored
schema -> names in dataframe_from_2d_array (#327)
1 parent d896e65 commit caf0689

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

spec/API_specification/dataframe_api/__init__.py

+19-9
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,8 @@ def column_from_1d_array(array: Any, *, name: str = "") -> Column:
138138
See `dataframe_from_2d_array` for related 2D function.
139139
140140
Only Array-API-compliant 1D arrays are supported.
141-
Cross-kind casting is undefined and may vary across implementations.
142-
Downcasting is disallowed.
143141
144-
The resulting column will have the dtype to the
142+
The resulting column will have the dtype corresponding to the
145143
Array API one:
146144
147145
- 'bool' -> Bool()
@@ -170,22 +168,34 @@ def column_from_1d_array(array: Any, *, name: str = "") -> Column:
170168
...
171169

172170

173-
def dataframe_from_2d_array(array: Any, *, schema: dict[str, DType]) -> DataFrame:
171+
def dataframe_from_2d_array(array: Any, *, names: Sequence[str]) -> DataFrame:
174172
"""Construct DataFrame from 2D array.
175173
176174
See `column_from_1d_array` for related 1D function.
177175
178176
Only Array-API-compliant 2D arrays are supported.
179-
Cross-kind casting is undefined and may vary across implementations.
180-
Downcasting is disallowed.
177+
178+
The resulting columns will have the dtype corresponding to the
179+
Array API one:
180+
181+
- 'bool' -> Bool()
182+
- 'int8' -> Int8()
183+
- 'int16' -> Int16()
184+
- 'int32' -> Int32()
185+
- 'int64' -> Int64()
186+
- 'uint8' -> UInt8()
187+
- 'uint16' -> UInt16()
188+
- 'uint32' -> UInt32()
189+
- 'uint64' -> UInt64()
190+
- 'float32' -> Float32()
191+
- 'float64' -> Float64()
181192
182193
Parameters
183194
----------
184195
array : array
185196
array-API compliant 2D array
186-
dtypes : Mapping[str, DType]
187-
Dtype of each column. Must be the same length as ``array.shape[1]``.
188-
Keys determine column names.
197+
names : Sequence[str]
198+
Names to give columns.
189199
190200
Returns
191201
-------

spec/API_specification/dataframe_api/typing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def dataframe_from_2d_array(
116116
self,
117117
array: Any,
118118
*,
119-
schema: dict[str, DType],
119+
names: Sequence[str],
120120
) -> DataFrame:
121121
...
122122

spec/API_specification/examples/04_datatypes.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,5 @@ def main(df_raw: SupportsDataFrameAPI) -> SupportsDataFrameAPI:
2020
)
2121
arr = df.to_array(namespace.Int64())
2222
arr = some_array_function(arr)
23-
df = namespace.dataframe_from_2d_array(
24-
arr,
25-
schema={"a": df.col("a").dtype, "b": namespace.Float64()},
26-
)
23+
df = namespace.dataframe_from_2d_array(arr, names=["a", "b"])
2724
return df.dataframe

0 commit comments

Comments
 (0)