@@ -180,9 +180,9 @@ def get_rows_by_mask(self, mask: Column[Bool]) -> DataFrame:
180
180
"""
181
181
...
182
182
183
- def insert_column (self , column : Column [Any ]) -> DataFrame :
183
+ def insert_columns (self , columns : Column [Any ] | Sequence [ Column [ Any ] ]) -> DataFrame :
184
184
"""
185
- Insert column into DataFrame at rightmost location.
185
+ Insert column(s) into DataFrame at rightmost location.
186
186
187
187
The column's name will be used as the label in the resulting dataframe.
188
188
To insert the column with a different name, combine with `Column.rename`,
@@ -203,19 +203,8 @@ def insert_column(self, column: Column[Any]) -> DataFrame:
203
203
df = df.insert_column(new_column.rename('a_plus_1'))
204
204
df = df.get_columns_by_name(new_column_names)
205
205
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
219
208
220
209
.. code-block::
221
210
@@ -241,17 +230,15 @@ def insert_columns(self, columns: Sequence[Column[Any]]) -> DataFrame:
241
230
242
231
Parameters
243
232
----------
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`.
255
242
"""
256
243
...
257
244
0 commit comments