Skip to content

Inconsistent behaviour on sep/delimiter for pandas.read_csv #21996

Open
@dahlbaek

Description

@dahlbaek

Related: #7662

Code Sample, a copy-pastable example if possible

from io import StringIO

import pandas as pd


CSV = "a|b\n1|2"
print(pd.read_csv(StringIO(CSV), sep=None, engine='python'))
print('is not the same as')
print(pd.read_csv(StringIO(CSV), delimiter=None, engine='python'))
print('\nand no warning is emitted by')
print(pd.read_csv(StringIO(CSV), sep='|', delimiter=' '))

Problem description

According to the documentation,

delimiter : str, default None
    Alternative argument name for sep.

Thus, I would expect sep and delimiter to be interchangable.

Expected Output

Specifying delimiter=None is equivalent to specifying sep=None, and specifying both sep and delimiter emits a warning or causes an error. Alternatively, either sep or delimiter should be deprecated.

Output of pd.show_versions()

No module named 'dask'

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Linux
OS-release: 4.13.0-45-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL:
LANG: en_DK.UTF-8
LOCALE: en_DK.UTF-8

pandas: 0.24.0.dev0+332.g1f6ddc4
pytest: 3.6.3
pip: 10.0.1
setuptools: 39.0.1
Cython: 0.28.4
numpy: 1.14.5
scipy: 1.1.0
pyarrow: 0.9.0
xarray: 0.10.7
IPython: 6.4.0
sphinx: 1.7.5
patsy: None
dateutil: 2.7.3
pytz: 2018.5
blosc: 1.5.1
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.5
feather: 0.4.0
matplotlib: 2.2.2
openpyxl: 2.5.4
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.5
lxml: 4.2.3
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.2.9
pymysql: 0.9.2
psycopg2: None
jinja2: 2.10
s3fs: 0.1.5
fastparquet: 0.1.5
pandas_gbq: None
pandas_datareader: None
gcsfs: 0.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    API - ConsistencyInternal Consistency of API/BehaviorDeprecateFunctionality to remove in pandasIO CSVread_csv, to_csv

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions