导入数据
import pandas as pd
df = pd.DataFrame([['liver','E',89,21,24,64],
['Arry','C',36,37,37,57],
['Ack','A',57,60,18,84],
['Eorge','C',93,96,71,78],
['Oah','D',65,49,61,86]
],
columns = ['name','team','Q1','Q2','Q3','Q4'])
df
上述DataFrame中的index索引列默认是从0开始的,那么我们如何设置index索引列起始值从1开始呢?
方法1
df.index = df.index + 1
方法2
df.index = range(1,len(df)+1)
df