BUG: read_table raises ValueError when delim_whitespace is set to True · Issue #35958 · pandas-dev/pandas (original) (raw)
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of pandas.
- (optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
import io import pandas as pd
Build a simple space delimited file buffer to read
f = io.StringIO("a b c\n1 -2 -3\n4 5 6")
This raises an error
df = pd.read_table(f, delim_whitespace=True)
Setting the "sep" parameter as suggested in the docs works
df = pd.read_table(f, sep='\s+')
print(df)
Not setting the delim_whitespace parameter or setting it to False works,
but without correct formatting.
df = pd.read_table(f)
print(df)
Problem description
If you set the delim_whitespace to True when calling read_table() on a space delimited file, I get the following exception:
ValueError: Specified a delimiter with both sep and delim_whitespace=True; you can only specify one.
Expected Output
I would expect the same output as you get if the sep='\s+' parameter is set (as suggested in the docs).
Output of pd.show_versions()
INSTALLED VERSIONS
commit : f2ca0a2
python : 3.6.10.final.0
python-bits : 64
OS : Darwin
OS-release : 18.7.0
Version : Darwin Kernel Version 18.7.0: Thu Jun 18 20:50:10 PDT 2020; root:xnu-4903.278.43~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.1
numpy : 1.18.5
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 49.6.0.post20200814
Cython : None
pytest : 5.4.3
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.16.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None