How can I change a specific row label in a Pandas dataframe?
You can get the last index using negative indexing similar to that in Python
last = df.index[-1]
Then
df = df.rename(index={last: 'a'})
Edit: If you are looking for a one-liner,
df.index = df.index[:-1].tolist() + ['a']
use index
attribute:
df.index = df.index[:-1].append(pd.Index(['A']))