Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 导出到excel时打印订单列_Python_Excel_Pandas_Dataframe_Export To Excel - Fatal编程技术网

Python 导出到excel时打印订单列

Python 导出到excel时打印订单列,python,excel,pandas,dataframe,export-to-excel,Python,Excel,Pandas,Dataframe,Export To Excel,我将一些数据从Python/pandas导出到Excel,其中包括一个表示顺序的列。例如: +----+---------+------------------+------+------+---------+ | | Name | Task | Team | Date | Month | +----+---------+------------------+------+------+---------+ | 0 | John | Market

我将一些数据从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 |
+----+---------+------------------+------+------+---------+

问题是,当我将文件导入pandas时,对于我的计算机,最左边表示顺序的列没有被考虑在内;而对其他人来说,它是。为什么,解决方法是什么?

使用
df.to_excel(file.xlsx,index=False)
保存到file.xlsx而不使用索引

您能澄清一下您的陈述吗?您的excel文件是否有索引列(最左边的列),当您使用
pandas
导入它时,它会消失?您好,我的代码没有索引列。但是,当我导出到excel时,它会这样做。当我导入相同的excel文件时,对于某些人来说,它会将索引列作为数据框中的一列加载;但是,对于我的计算机,它不是。当导出到excel时,设置index=False
df.to_excel(index=False)
“我将一些代码导出到excel(格式)”错误,否。您将一些数据导出到excel。你没有告诉我们你从哪里出口的,我想你是指一些电子表格包,但你的意思是“从熊猫出口”。我们不知道你从哪里出口的。你必须陈述你的问题,“最左边代表顺序的列”被称为索引。因此,您的问题是“当我将数据(从pandas)导出到Excel时,索引被删除”,或者“当我将Excel文件读入pandas时,索引被删除”。