daft.DataFrame.with_columns_renamed

daft.DataFrame.with_columns_renamed#

DataFrame.with_columns_renamed(cols_map: Dict[str, str]) DataFrame[source]#

Renames multiple columns in the current DataFrame.

If the columns in the DataFrame schema do not exist, this will be a no-op.

Example

>>> import daft
>>> df = daft.from_pydict({"x": [1, 2, 3], "y": [4, 5, 6]})
>>> df.with_columns_renamed({"x": "foo", "y": "bar"}).show()
╭───────┬───────╮
│ foo   ┆ bar   │
│ ---   ┆ ---   │
│ Int64 ┆ Int64 │
╞═══════╪═══════╡
│ 1     ┆ 4     │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 2     ┆ 5     │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 3     ┆ 6     │
╰───────┴───────╯

(Showing first 3 of 3 rows)
Parameters:

cols_map (Dict[str, str]) – Dictionary of columns to rename in the format { existing: new }

Returns:

DataFrame with the columns renamed.

Return type:

DataFrame