Search code examples
pythonexcelpandasdataframeexport-to-excel

Pandas printing column of order when export to excel


I exported some data from Python/pandas to Excel, and it includes a column that represents the order. Example:


+----+---------+------------------+------+------+---------+
|    | 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 |
+----+---------+------------------+------+------+---------+

The problem is that when I import the file back into pandas, for my computer, the column on the far left that represents order is not taken into account; whereas for other people, it is. Why, and what's the solution?


Solution

  • use df.to_excel(file.xlsx, index=False) to save to file.xlsx without the index