熊猫read_csv函数失败

时间:2018-12-06 23:05:55

标签: python-3.x pandas

我正在尝试简单地将以下csv转换为数据框:

    import pandas as pd
    ticket = pd.read_csv("file.csv")

但是,由于csv第一栏中缺少引号:

 A,"B","C","D"

 0,"1","2","3"

它无法正确地将每一行分配给其合法的标头。

1 个答案:

答案 0 :(得分:0)

import pandas as pd
df = pd.read_csv('your_csv.csv')

IN [1]: df
Out[1]: 
   A  "B"  "C"  "D"
0  0  "1"  "2"  "3"

似乎可以通过将给定数据放入.csv来为我工作,您可以更详细地说明该错误吗?