数据mydata.csv:链接:https://pan.baidu.com/s/1Z6CQbpB6-8ZnpUGp-QQNeQ
提取码:2slm
data1 = pd.read_csv(r'C:/Users/Administrator/Desktop/mydata.csv',index_col=0)
print(data1)
mean median
市值
(0, 30] 2.708391 2.4060
(30, 80] 1.616482 1.1795
(80, 150] 0.709489 0.3960
(150, 300] -0.005208 0.0000
(300, 500] -0.008092 -0.2450
(500, 1000] -0.199611 -0.1855
(1000, 2000] -0.391432 -0.2880
(2000, 30000] 0.727273 0.6880
'市值’为索引,此索引的值在plotly模块中使用会出错
data1.reset_index(drop=True)
mean median
0 2.708391 2.4060
1 1.616482 1.1795
2 0.709489 0.3960
3 -0.005208 0.0000
4 -0.008092 -0.2450
5 -0.199611 -0.1855
6 -0.391432 -0.2880
7 0.727273 0.6880
data1.reset_index()
市值 mean median
0 (0, 30] 2.708391 2.4060
1 (30, 80] 1.616482 1.1795
2 (80, 150] 0.709489 0.3960
3 (150, 300] -0.005208 0.0000
4 (300, 500] -0.008092 -0.2450
5 (500, 1000] -0.199611 -0.1855
6 (1000, 2000] -0.391432 -0.2880
7 (2000, 30000] 0.727273 0.6880
drop=True的作用把原来的索引丢弃或者转换为对应列