jim jarnac
jim jarnac

Reputation: 5152

python pandas - turn the name of a pandas series into a value

I have a serie that is as follow:

MFE_ts            2000-02-01 02:30:00
MAE_pr                        1400.75
MAE_ts             949383000000000000
MAE                               1.5
netgain_by_MAE                1.33333
Name: 2000-02-01 02:30:00, dtype: object

I would like to turn the name of the serie into a value and to give a new name to the serie to achieve a result such as :

exit_time         2000-02-01 02:30:00
MFE_ts            2000-02-01 02:30:00
MAE_pr                        1400.75
MAE_ts             949383000000000000
MAE                               1.5
netgain_by_MAE                1.33333
Name: entry_time, dtype: object

How could I achieve that?

Thanks!

Upvotes: 0

Views: 53

Answers (1)

user2720264
user2720264

Reputation:

Supposing s is your series, you can achieve it like this:

s['exit_time'] = s.name
s.name = 'entry_time'

Upvotes: 1

Related Questions