Skip to content

Commit 3fd9f30

Browse files
committed
dataframe_from_dict -> dataframe_from_columns
1 parent f821dbe commit 3fd9f30

File tree

4 files changed

+11
-20
lines changed

4 files changed

+11
-20
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/_types.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,16 @@ def column_from_sequence(
125125
*,
126126
dtype: Any,
127127
name: str = "",
128-
api_version: str | None = None,
129128
) -> ColumnType:
130129
...
131130

132131
@staticmethod
133-
def dataframe_from_dict(
134-
data: Mapping[str, ColumnType], *, api_version: str | None = None
135-
) -> DataFrameType:
132+
def dataframe_from_columns(*columns: ColumnType) -> DataFrameType:
136133
...
137134

138135
@staticmethod
139136
def column_from_1d_array(
140-
array: Any, *, dtype: Any, name: str = "", api_version: str | None = None
137+
array: Any, *, dtype: Any, name: str = ""
141138
) -> ColumnType:
142139
...
143140

@@ -147,7 +144,6 @@ def dataframe_from_2d_array(
147144
*,
148145
names: Sequence[str],
149146
dtypes: Mapping[str, Any],
150-
api_version: str | None = None,
151147
) -> DataFrameType:
152148
...
153149

spec/API_specification/examples/02_plotting.py

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

1616
namespace = x.__column_namespace__()
1717

18-
df = namespace.dataframe_from_dict({"x": x, "y": y, "color": color})
18+
df = namespace.dataframe_from_columns(
19+
x.rename('x'), y.rename('y'), color.rename('color')
20+
)
1921

2022
agg = df.group_by("color").mean()
2123
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)