pandas.read_csv() 方法中的 `sep` 和 `delimiter` 属性有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49532873/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between `sep` and `delimiter` attributes in pandas.read_csv() method?
提问by GadaaDhaariGeek
What is the difference between sep
and delimiter
attributes in pandas.read_csv()
method?
sep
和方法中的delimiter
属性有什么区别pandas.read_csv()
?
Also what is the situation when I would choose one over the other?
另外,当我选择一个而不是另一个时的情况是什么?
In documentation I read something about Python builtin sniffer tool, also in delimiter, it says alternative argument name for sep, then why cant we have only one attribute?
在文档中,我阅读了一些关于 Python 内置嗅探器工具的内容,也在分隔符中,它说sep 的替代参数名称,那么为什么我们不能只有一个属性?
回答by thesilkworm
Confirmation that they are the same thing can be found in the source code:
可以在源代码中确认它们是同一件事:
# Alias sep -> delimiter.
if delimiter is None:
delimiter = sep
I agree with the other answer that it is best to stick to sep
. It seems to be more commonly used, and it is more consistent with other functions such as to_csv
, which does not accept delimiter
, only sep
.
我同意最好坚持的另一个答案sep
。好像比较常用,也比较符合其他函数比如to_csv
,不接受delimiter
,只接受sep
。