我有一个excelfile,其内容如下所示,
this is is the line we want to ignore
id name dept deptid
2 abc it 1
3 xyz mech 2
1 mno stats 3
请注意,我需要跳过的前两行。第一行是一行,第二行是标题。
我正在使用以下命令,
import pandas as pd
pd.read_excel(my file, sheet_name=1, skip_rows=[ i for i in range(2)])
输出一切都很好,除了它将Deptid列的第一个值1转换为1.1
如果我给其他任何号码都可以的话。
请提出原因。
答案 0 :(得分:0)
在Excel中打开文件。我敢打赌deptid
在第一个单元格中的实际值为1.1,但是您应用了一些格式设置,以防止显示小数位数。因此,即使Excel不能以这种方式显示数据,其数据实际上也是1.1。当您打开文件并单击单元格时,您会看到,然后在编辑栏中查看真正存在的文本。