8000 Add DataFrame.update_columns (#232) · data-apis/dataframe-api@3fa0b64 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3fa0b64

Browse files
authored
Add DataFrame.update_columns (#232)
* add DataFrame.update_column and DataFrame.update_columns * single update_columns, remove independence
1 parent 046449d commit 3fa0b64

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

spec/API_specification/dataframe_api/dataframe_object.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,31 @@ def insert_column(self, column: Column[Any]) -> DataFrame:
209209
"""
210210
...
211211

212+
def update_columns(self, columns: Column[Any] | Sequence[Column[Any]], /) -> DataFrame:
213+
"""
214+
Update values in existing column(s) from Dataframe.
215+
216+
The column's name will be used to tell which column to update.
217+
To update a column with a different name, combine with :meth:`Column.rename`,
218+
e.g.:
219+
220+
.. code-block:: python
221+
222+
new_column = df.get_column_by_name('a') + 1
223+
df = df.update_column(new_column.rename('b'))
224+
225+
Parameters
226+
----------
227+
columns : Column | Sequence[Column]
228+
Column(s) to update. If updating multiple columns, they must all have
229+
different names.
230+
231+
Returns
232+
-------
233+
DataFrame
234+
"""
235+
...
236+
212237
def drop_column(self, label: str) -> DataFrame:
213238
"""
214239
Drop the specified column.

0 commit comments

Comments
 (0)
0