pyspark.pandas.DataFrame.add_prefix#

DataFrame.add_prefix(prefix)[source]#

Prefix labels with string prefix.

For Series, the row labels are prefixed. For DataFrame, the column labels are prefixed.

Parameters
prefixstr

The string to add before each label.

Returns
DataFrame

New DataFrame with updated labels.

See also

Series.add_prefix

Prefix row labels with string prefix.

Series.add_suffix

Suffix row labels with string suffix.

DataFrame.add_suffix

Suffix column labels with string suffix.

Examples

>>> df = ps.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]}, columns=['A', 'B'])
>>> df
   A  B
0  1  3
1  2  4
2  3  5
3  4  6
>>> df.add_prefix('col_')
   col_A  col_B
0      1      3
1      2      4
2      3      5
3      4      6