warrick11
warrick11

Reputation: 135

Trying to change the index column of a Pandas Series?

I have a Pandas Series, it looks like this when I output it to a CSV-

a_x,8
b_x,14
c_x,18
d_x,26
e_x,32

Here is the result I am trying to achieve-

a_bar,8
b_bar,14
c_bar,18
d_bar,26
e_bar,32

Seems like a simple operation but just can't get the result yet. Thank you.

Upvotes: 2

Views: 4612

Answers (1)

warrick11
warrick11

Reputation: 135

solution=

df.index = df.index.str.replace('x', 'bar')

solved by Mitch, thanks

Upvotes: 3

Related Questions