对于\n
,我将使用与pandas.read_csv()
不同的行定界符。有人知道怎么做吗?
在read_csv()
的文档中,没有发现任何相关信息,但是在to_csv()
页面中,我找到了参数line_terminator
。
我该如何解决这个问题?
答案 0 :(得分:1)
这里是一个例子:
文件:a.csv
hello,world:hell,worl:hel,wor:he,wo
a = pd.read_csv('a.csv', lineterminator=':')
print(a)
输出:
hello world
0 hell worl
1 hel wor
2 he wo