daft.DataFrame.with_column_renamed

daft.DataFrame.with_column_renamed#

DataFrame.with_column_renamed(existing: str, new: str) DataFrame[source]#

Renames a column in the current DataFrame.

If the column in the DataFrame schema does 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_column_renamed("x", "foo").show()
╭───────┬───────╮
│ foo   ┆ y     │
│ ---   ┆ ---   │
│ Int64 ┆ Int64 │
╞═══════╪═══════╡
│ 1     ┆ 4     │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 2     ┆ 5     │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 3     ┆ 6     │
╰───────┴───────╯

(Showing first 3 of 3 rows)
Parameters:
  • existing (str) – name of the existing column to rename

  • new (str) – new name for the column

Returns:

DataFrame with the column renamed.

Return type:

DataFrame