[ Web Proxy ]
URL:
Viewing: https://dataframes.bigquery.dev/reference/api/bigframes.pandas.DataFrame.rename.html [Back]  [Original]

bigframes.pandas.DataFrame.rename — bigframes documentation
Back to top
Search the docs ...:

bigframes.pandas.DataFrame.rename#

DataFrame.rename(*, columns: Mapping[blocks.Label, blocks.Label]) DataFrame[source]#
DataFrame.rename(*, columns: Mapping[blocks.Label, blocks.Label], inplace: Literal[False]) DataFrame
DataFrame.rename(*, columns: Mapping[blocks.Label, blocks.Label], inplace: Literal[True]) None

Rename columns.

Dict values must be unique (1-to-1). Labels not contained in a dict will be left as-is. Extra labels listed dont throw an error.

Examples:

>>> df = bpd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
>>> df
   A  B
0  1  4
1  2  5
2  3  6

[3 rows x 2 columns]

Rename columns using a mapping:

>>> df.rename(columns={"A": "col1", "B": "col2"})
   col1  col2
0     1     4
1     2     5
2     3     6

[3 rows x 2 columns]
Parameters:
  • columns (Mapping) Dict-like from old column labels to new column labels.

  • inplace (bool) Default False. Whether to modify the DataFrame rather than creating a new one.

Returns:

DataFrame with the renamed axis labels or None if inplace=True.

Return type:

bigframes.pandas.DataFrame | None

Raises:

KeyError If any of the labels is not found.


Web Proxy Viewer  |  New URL  |  Original Page