0
import pandas as pd
data1 = {'name': ['wang','xiao','lin','du','cui'], 'chi': [82,93,75,97,85],'py':[86,94,86,68,98]} 
frame1=pd.DataFrame(data1)
print(frame1)

how can I change the default index 0 1 2 3 4 into a b c d e? Please advise me about this, thanks.

  • 1
    This has already been answered [here](https://stackoverflow.com/questions/19851005/rename-pandas-dataframe-index). – Joel Jul 02 '18 at 14:59
  • Possible duplicate of [Rename Pandas DataFrame Index](https://stackoverflow.com/questions/19851005/rename-pandas-dataframe-index) – BenG Jul 02 '18 at 15:02
  • Have you read this post: [enter link description here](https://stackoverflow.com/questions/19851005/rename-pandas-dataframe-index) – RomB Jul 02 '18 at 15:03

1 Answers1

0

To change the values of index from 0 1 2 3 4 into a b c d e use:

frame1.index = list('abcde')
zipa
  • 27,316
  • 6
  • 40
  • 58