Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
s = pd.Series([2, 3, 4, 5])
s
Out[2]:
0    2
1    3
2    4
3    5
dtype: int64
In [3]:
s.add_prefix('item_')
Out[3]:
item_0    2
item_1    3
item_2    4
item_3    5
dtype: int64
In [4]:
df = pd.DataFrame({'P': [2, 3, 4, 5],  'Q': [4, 5, 6, 7]})
df
Out[4]:
P Q
0 2 4
1 3 5
2 4 6
3 5 7
In [5]:
df.add_prefix('col_')
Out[5]:
col_P col_Q
0 2 4
1 3 5
2 4 6
3 5 7