导出到Excel时的熊猫打印订单列

时间:2019-09-24 22:14:54

标签: python excel pandas dataframe export-to-excel

我将一些数据从Python / pandas导出到Excel,其中包括代表订单的列。示例:


+----+---------+------------------+------+------+---------+
|    | Name    | Task             | Team | Date | Month   |
+----+---------+------------------+------+------+---------+
| 0  | John    | Market study     | A    | 1    | Month 1 |
+----+---------+------------------+------+------+---------+
| 1  | Michael | Customer service | B    | 1    | Month 1 |
+----+---------+------------------+------+------+---------+
| 2  | Joanna  | Accounting       | C    | 1    | Month 1 |
+----+---------+------------------+------+------+---------+
| 3  | John    | Accounting       | B    | 2    | Month 1 |
+----+---------+------------------+------+------+---------+
| 4  | Michael | Customer service | A    | 2    | Month 1 |
+----+---------+------------------+------+------+---------+
| 5  | Joanna  | Market study     | C    | 2    | Month 1 |
+----+---------+------------------+------+------+---------+
| 6  | John    | Market study     | A    | 1    | Month 3 |
+----+---------+------------------+------+------+---------+
| 7  | Michael | Customer service | B    | 1    | Month 3 |
+----+---------+------------------+------+------+---------+
| 8  | Joanna  | Accounting       | C    | 1    | Month 3 |
+----+---------+------------------+------+------+---------+
| 9  | John    | Customer service | A    | 2    | Month 3 |
+----+---------+------------------+------+------+---------+
| 10 | Michael | Accounting       | B    | 2    | Month 3 |
+----+---------+------------------+------+------+---------+

问题是,当我将文件导入大熊猫时,对于我的计算机,不考虑表示顺序的最左端的列;而对于其他人,确实如此。为什么,解决方案是什么?

1 个答案:

答案 0 :(得分:0)

使用df.to_excel(file.xlsx, index=False)保存到没有索引的file.xlsx