I’m using python pandas for data analysis and I want to change the name of a series in a dataframe.
This works, but it seems very inefficient:
AA = pandas.DataFrame( A )
for series in A:
AA[A_prefix+series] = A[series]
del A[series]
Is there a way to change the series name in place?
Sure, you can use the rename method:
This doesn’t change
df, though:You can get that behaviour if you want using
inplace: