a=['序号',1,2,3,4,5]
b=['成本',20,45,12,34,67]
import pandas
c=pandas.Series(a)
d=pandas.Series(b)
e=pandas.DataFrame(list(zip(c,d)))
print(e)
0 1
0 序号 成本
1 1 20
2 2 45
3 3 12
4 4 34
5 5 67
#设置新列名
e.columns=['序号','成本']
#重置索引
e=e.drop(0,axis=0).reset_index()
e.drop('index',axis=1,inplace=True)
print(e)
序号 成本
0 1 20
1 2 45
2 3 12
3 4 34
4 5 67
来源:oschina
链接:https://my.oschina.net/u/4375161/blog/4326140