pandas: read_csv/to_csv sep/delimiter inconsistency
related #7615
Bit of a UI problem here (although it’s behaving as the docstring says it does, so it doesn’t quite qualify as a bug):
>>> df = pd.DataFrame({"A": [1,2,3], "B": [4,5,6]})
>>> df.to_csv("tmp.csv", sep=";")
>>> !cat tmp.csv
;A;B
0;1;4
1;2;5
2;3;6
>>> df.to_csv("tmp.csv", delimiter=";")
>>> !cat tmp.csv
,A,B
0,1,4
1,2,5
2,3,6
read_csv accepts both sep and delimiter but to_csv silently ignores delimiter. Someone was recently tripped up by this on SO. I’m fine with either teaching to_csv to behave the same way read_csv does or, alternatively, raising if delimiter is found as a keyword.
That is, I’m less bothered by the inconsistency than the silent unexpected behaviour.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 19 (12 by maintainers)
@gfyoung wrote:
Any update on this? Is ‘not now’ now?