Skip to content

Commit 3a0efcf

Browse files
committed
just have insert_columns
1 parent 45fb1ca commit 3a0efcf

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

spec/API_specification/dataframe_api/dataframe_object.py

+13-26
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ def get_rows_by_mask(self, mask: Column[Bool]) -> DataFrame:
180180
"""
181181
...
182182

183-
def insert_column(self, column: Column[Any]) -> DataFrame:
183+
def insert_columns(self, columns: Column[Any] | Sequence[Column[Any]]) -> DataFrame:
184184
"""
185-
Insert column into DataFrame at rightmost location.
185+
Insert column(s) into DataFrame at rightmost location.
186186
187187
The column's name will be used as the label in the resulting dataframe.
188188
To insert the column with a different name, combine with `Column.rename`,
@@ -203,19 +203,8 @@ def insert_column(self, column: Column[Any]) -> DataFrame:
203203
df = df.insert_column(new_column.rename('a_plus_1'))
204204
df = df.get_columns_by_name(new_column_names)
205205
206-
Parameters
207-
----------
208-
column : Column
209-
"""
210-
...
211-
212-
def insert_columns(self, columns: Sequence[Column[Any]]) -> DataFrame:
213-
"""
214-
Insert columns into DataFrame at rightmost location.
215-
216-
Like :meth:`insert_column`, but can insert multiple (independent) columns.
217-
Some implementations may be able to make use of parallelism in this
218-
case. For example instead of:
206+
If inserting multiple columns, they must be indepedent.
207+
For example, instead of
219208
220209
.. code-block::
221210
@@ -241,17 +230,15 @@ def insert_columns(self, columns: Sequence[Column[Any]]) -> DataFrame:
241230
242231
Parameters
243232
----------
244-
columns : Sequence[Column]
245-
Sequence of `Column`s.
246-
Must be independent of each other.
247-
Column names must be unique.
248-
Column names may not already be present in the
249-
dataframe - use :meth:`Column.rename` to rename them
250-
beforehand if necessary.
251-
252-
Returns
253-
-------
254-
DataFrame
233+
columns : Column | Sequence[Column]
234+
Column(s) to insert. Must be independent of each other. For example,
235+
236+
.. code-block:: python
237+
new_column_1 = df.get_column_by_name('a').rename('b')
238+
new_column_2 = (new_column_1 + 2).rename('c')
239+
df.insert_columns([new_column_1, new_column_2])
240+
241+
is not allowed, as `new_column_2` depends on `new_column_1`.
255242
"""
256243
...
257244

0 commit comments

Comments
 (0)