-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: read_csv inconsistent behavior #57792
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
Comments
I believe in your df1, pandas has used the first line as the header. However, headers should be distinct and hence pandas has added the ".1", ".2", ".3", etc. to all the headers that are the same, i.e. 0, to differentiate them. |
Correct @wleong1 - I think this behavior should be documented in the docstring of read_csv for the header argument. |
Noted, thanks! |
Is anybody working on that? If Not, I could help here. |
Hi @rhshadrach I noticed that this issue is currently unassigned, and I'm interested in working on it. Could you please assign it to me? I believe I can contribute to document in the docstring of read_csv for the header argument (as per you mentioned). Thanks! |
is this still open for contribution , im new to open source please be kind ? |
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
Issue Description
Columns are incorrectly read from CSV
Expected Behavior
df1.columns.tolist() being the same as df2.iloc[0].tolist()
i.e.: [0.0, 1.992422433360555e-06, 0.0, 1.992422433374335e-06, 0.0, 0.0, 0.0, 0.0186775088050425, 0.0, 0.8, 0.0, 0.0027224134027627, 0.0, 0.0027224132787975]
However, it is:
['0', '1.992422433360555e-06', '0.1', '1.992422433374335e-06', '0.2', '0.3', '0.4', '0.01867750880504259', '0.5', '0.8', '0.6', '0.002722413402762714', '0.7', '0.002722413278797551']
which is not any row in the file
Installed Versions
INSTALLED VERSIONS
commit : bdc79c1
python : 3.9.7.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.133.1-microsoft-standard-WSL2
Version : #1 SMP Thu Oct 5 21:02:42 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.1
numpy : 1.26.4
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.2.2
pip : 23.3.1
Cython : None
pytest : 7.4.1
hypothesis : None
sphinx : 5.0.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.3
IPython : 8.15.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.2
bottleneck : 1.3.7
dataframe-api-compat : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.8.0
numba : None
numexpr : 2.8.7
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : None
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.11.4
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: