Skip to content

BUG: skiprows ignored in read_csv(engine="pyarrow") #58048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
rohanjain101 opened this issue Mar 28, 2024 · 5 comments
Open
3 tasks done

BUG: skiprows ignored in read_csv(engine="pyarrow") #58048

rohanjain101 opened this issue Mar 28, 2024 · 5 comments
Assignees
Labels
Arrow pyarrow functionality Bug IO CSV read_csv, to_csv

Comments

@rohanjain101
Copy link
Contributor

rohanjain101 commented Mar 28, 2024

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

>>> data = """a\nb\nc"""
>>> pd.read_csv(StringIO(data), engine="pyarrow")
   a
0  b
1  c
>>> pd.read_csv(StringIO(data), engine="pyarrow", skiprows=1)
   a
0  b
1  c
>>>

Issue Description

skiprows seems to be ignored

Expected Behavior

The first row should be skipped, and the returned df should contain same data as default csv engine.

Installed Versions

INSTALLED VERSIONS

commit : bdc79c1
python : 3.11.8.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.22631
machine : AMD64
processor : Intel64 Family 6 Model 151 Stepping 2, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252

pandas : 2.2.1
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.8.2
setuptools : 69.0.3
pip : 23.3.2
Cython : None
pytest : None
hypothesis : None
sphinx : 4.2.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.3
IPython : 8.21.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.2.0
gcsfs : None
matplotlib : 3.8.3
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 15.0.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.12.0
sqlalchemy : None
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None

@rohanjain101 rohanjain101 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 28, 2024
@ashorkey-umich
Copy link

take

@kymcglyn
Copy link

take

@rohanjain101
Copy link
Contributor Author

From looking at the code, it seems skiprows is only honored if header=None for pyarrow types, but this is different from the default csv engine.

@kymcglyn kymcglyn removed their assignment May 3, 2024
@mroeschke mroeschke added IO CSV read_csv, to_csv Arrow pyarrow functionality and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 8, 2024
@jaketear
Copy link

jaketear commented Dec 3, 2024

I can also reproduce this issue in pandas 2.2.3. But, it seems correct when using header=1 instead of skiprows=1.

data = """a\nb\nc"""
pd.read_csv(StringIO(data), engine="pyarrow", skiprows=1)
Out[8]: 
   a
0  b
1  c
pd.read_csv(StringIO(data), engine="pyarrow", header=1)
Out[9]: 
   b
0  c

@snitish
Copy link
Member

snitish commented Dec 7, 2024

Any thoughts on disabling the header parameter for engine="pyarrow"? The official pyarrow.csv.read_csv documentation doesn't seem to support header anyway. That way, we only have skiprows and this issue should be fixed. @mroeschke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Bug IO CSV read_csv, to_csv
Projects
None yet
Development

No branches or pull requests

6 participants