Skip to content

Commit 78c8e5d

Browse files
authored
dataframe_from_dict -> dataframe_from_columns (#276)
1 parent ac6cafd commit 78c8e5d

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

spec/API_specification/dataframe_api/__init__.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"column_from_sequence",
2121
"column_from_1d_array",
2222
"concat",
23-
"dataframe_from_dict",
23+
"dataframe_from_columns",
2424
"dataframe_from_2d_array",
2525
"is_null",
2626
"null",
@@ -91,27 +91,20 @@ def column_from_sequence(sequence: Sequence[Any], *, dtype: DType, name: str = '
9191
"""
9292
...
9393

94-
def dataframe_from_dict(data: Mapping[str, Column]) -> DataFrame:
94+
def dataframe_from_columns(*columns: Column) -> DataFrame:
9595
"""
96-
Construct DataFrame from map of column names to Columns.
96+
Construct DataFrame from sequence of Columns.
9797
9898
Parameters
9999
----------
100-
data : Mapping[str, Column]
101-
Column must be of the corresponding type of the DataFrame.
100+
columns : Column
101+
Column(s) must be of the corresponding type of the DataFrame.
102102
For example, it is only supported to build a ``LibraryXDataFrame`` using
103103
``LibraryXColumn`` instances.
104104
105105
Returns
106106
-------
107107
DataFrame
108-
109-
Raises
110-
------
111-
ValueError
112-
If any of the columns already has a name, and the corresponding key
113-
in `data` doesn't match.
114-
115108
"""
116109
...
117110

spec/API_specification/dataframe_api/typing.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ def column_from_sequence(
118118
...
119119

120120
@staticmethod
121-
def dataframe_from_dict(
122-
data: Mapping[str, Column]
123-
) -> DataFrame:
121+
def dataframe_from_columns(*columns: Column) -> DataFrame:
124122
...
125123

126124
@staticmethod

spec/API_specification/examples/02_plotting.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ def group_by_and_plot(
2020

2121
namespace = x.__column_namespace__()
2222

23-
df = namespace.dataframe_from_dict({"x": x, "y": y, "color": color})
23+
df = namespace.dataframe_from_columns(
24+
x.rename('x'), y.rename('y'), color.rename('color')
25+
)
2426

2527
agg = df.group_by("color").mean()
2628
x = agg.get_column_by_name("x").to_array_object(namespace.Float64())

spec/API_specification/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ of objects and functions in the top-level namespace. The latter are:
3434
is_dtype
3535
column_from_sequence
3636
column_from_1d_array
37-
dataframe_from_dict
37+
dataframe_from_columns
3838
dataframe_from_2d_array
3939

4040
The ``DataFrame``, ``Column`` and ``GroupBy`` objects have the following

0 commit comments

Comments
 (0)