@@ -179,53 +179,27 @@ def filter(self, mask: Column) -> DataFrame:
179
179
"""
180
180
...
181
181
182
- def insert_column (self , column : Column ) -> DataFrame :
182
+ def assign (self , columns : Column | Sequence [ Column ], / ) -> DataFrame :
183
183
"""
184
- Insert column into DataFrame at rightmost location .
184
+ Insert new column(s), or update values in existing ones .
185
185
186
- The column's name will be used as the label in the resulting dataframe.
187
- To insert the column with a different name, combine with `Column.rename`,
188
- e.g.:
186
+ If inserting new columns, the column's names will be used as the labels,
187
+ and the columns will be inserted at the rightmost location.
189
188
190
- .. code-block:: python
191
-
192
- new_column = df.get_column_by_name('a') + 1
193
- df = df.insert_column(new_column.rename('a_plus_1'))
194
-
195
- If you need to insert the column at a different location, combine with
196
- :meth:`select`, e.g.:
197
-
198
- .. code-block:: python
199
-
200
- new_column = df.get_column_by_name('a') + 1
201
- new_columns_names = ['a_plus_1'] + df.column_names
202
- df = df.insert_column(new_column.rename('a_plus_1'))
203
- df = df.select(new_column_names)
204
-
205
- Parameters
206
- ----------
207
- column : Column
208
- """
209
- ...
210
-
211
- def update_columns (self , columns : Column | Sequence [Column ], / ) -> DataFrame :
212
- """
213
- Update values in existing column(s) from Dataframe.
214
-
215
- The column's name will be used to tell which column to update.
216
- To update a column with a different name, combine with :meth:`Column.rename`,
217
- e.g.:
189
+ If updating existing columns, their names will be used to tell which columns
190
+ to update. To update a column with a different name, combine with
191
+ :meth:`Column.rename`, e.g.:
218
192
219
193
.. code-block:: python
220
194
221
195
new_column = df.get_column_by_name('a') + 1
222
- df = df.update_column (new_column.rename('b'))
196
+ df = df.assign (new_column.rename('b'))
223
197
224
198
Parameters
225
199
----------
226
200
columns : Column | Sequence[Column]
227
- Column(s) to update. If updating multiple columns, they must all have
228
- different names.
201
+ Column(s) to update/insert . If updating/inserting multiple columns,
202
+ they must all have different names.
229
203
230
204
Returns
231
205
-------
0 commit comments