如何使用多级索引操作指定格式的Pandas DataFrame?
我帮你把这个Pandas DataFrame整理成清晰易读的Markdown表格啦,你看看:
| 索引 | mesh | 分组1 | 分组2 | energy low [eV] | energy high [eV] | nuclide | score |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 1 | 1.00e-03 | 2.00e+07 | total flux | 0.00e+00 |
| 1 | 1 | 1 | 2 | 1.00e-03 | 2.00e+07 | total flux | 1.82e-03 |
| 2 | 1 | 1 | 3 | 1.00e-03 | 2.00e+07 | total flux | 6.96e-03 |
| 3 | 1 | 1 | 4 | 1.00e-03 | 2.00e+07 | total flux | 1.47e-03 |
| 4 | 1 | 1 | 5 | 1.00e-03 | 2.00e+07 | total flux | 6.93e-03 |
| 5 | 1 | 1 | 6 | 1.00e-03 | 2.00e+07 | total flux | 8.73e-03 |
| 6 | 1 | 1 | 7 | 1.00e-03 | 2.00e+07 | total flux | 1.34e-02 |
| 7 | 1 | 1 | 8 | 1.00e-03 | 2.00e+07 | total flux | 1.16e-02 |
| 8 | 1 | 1 | 9 | 1.00e-03 | 2.00e+07 | total flux | ... |
另外,如果你之后想自己从Pandas里直接导出这种Markdown格式的表格,用这个小代码就行:
import pandas as pd # 假设你的DataFrame变量名叫df print(df.to_markdown())
内容的提问来源于stack exchange,提问作者Sterling Butters
相关产品推荐
相关产品推荐

