Skip to content

Commit 27501f8

Browse files
authored
move from_sequence to namespace (data-apis#164)
* move from_sequence to namespace * rename, move from_dict out too * Update spec/API_specification/dataframe_api/__init__.py --------- Co-authored-by: MarcoGorelli <>
1 parent 68aeb8d commit 27501f8

File tree

2 files changed

+40
-20
lines changed

2 files changed

+40
-20
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,54 @@
11
"""
22
Function stubs and API documentation for the DataFrame API standard.
33
"""
4+
from __future__ import annotations
5+
6+
from typing import Mapping, Sequence
47

58
from .column_object import *
69
from .dataframe_object import *
710
from .groupby_object import *
811

12+
from ._types import dtype
13+
914

1015
__dataframe_api_version__: str = "YYYY.MM"
1116
"""
1217
String representing the version of the DataFrame API specification to which the
1318
conforming implementation adheres.
1419
"""
20+
21+
def column_from_sequence(sequence: Sequence[object], *, dtype: dtype) -> Column:
22+
"""
23+
Construct Column from sequence of elements.
24+
25+
Parameters
26+
----------
27+
sequence : Sequence[object]
28+
Sequence of elements. Each element must be of the specified
29+
``dtype``, the corresponding Python builtin scalar type, or
30+
coercible to that Python scalar type.
31+
dtype : str
32+
Dtype of result. Must be specified.
33+
34+
Returns
35+
-------
36+
Column
37+
"""
38+
...
39+
40+
def dataframe_from_dict(data: Mapping[str, Column]) -> DataFrame:
41+
"""
42+
Construct DataFrame from map of column names to Columns.
43+
44+
Parameters
45+
----------
46+
data : Mapping[str, Column]
47+
Column must be of the corresponding type of the DataFrame.
48+
For example, it is only supported to build a ``LibraryXDataFrame`` using
49+
``LibraryXColumn`` instances.
50+
51+
Returns
52+
-------
53+
DataFrame
54+
"""

spec/API_specification/dataframe_api/column_object.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,6 @@ class Column:
1717
constructor functions or an already-created dataframe object retrieved via
1818
1919
"""
20-
@classmethod
21-
def from_sequence(cls, sequence: Sequence[object], dtype: dtype) -> Column:
22-
"""
23-
Construct Column from sequence of elements.
24-
25-
Parameters
26-
----------
27-
sequence : Sequence[object]
28-
Sequence of elements. Each element must be of the specified
29-
``dtype``, the corresponding Python builtin scalar type, or
30-
coercible to that Python scalar type.
31-
dtype : str
32-
Dtype of result. Must be specified.
33-
34-
Returns
35-
-------
36-
Column
37-
"""
38-
...
39-
4020
def __len__(self) -> int:
4121
"""
4222
Return the number of rows.

0 commit comments

Comments
 (0)