Skip to content
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

pl.from_pandas(df, include_index=True) silently ignores index if it is named the same way as a column #15938

Closed
2 tasks done
MarcoGorelli opened this issue Apr 28, 2024 · 2 comments
Labels
A-interop-pandas Area: interoperability with pandas bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@MarcoGorelli
Copy link
Collaborator

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

df = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}, index=pd.Index([7,8,9], name='a'))
print(pl.from_pandas(df, include_index=True))

Log output

shape: (3, 2)
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 1   ┆ 4   │
│ 2   ┆ 5   │
│ 3   ┆ 6   │
└─────┴─────┘

Issue description

the index was silently excluded

Expected behavior

I think this should raise

Installed versions

--------Version info---------
Polars:               0.20.10
Index type:           UInt32
Platform:             Linux-5.15.146.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
Python:               3.11.9 (main, Apr  6 2024, 17:59:24) [GCC 11.4.0]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          3.0.0
connectorx:           <not installed>
deltalake:            <not installed>
fsspec:               2024.3.1
gevent:               <not installed>
hvplot:               0.9.2
matplotlib:           3.8.4
numpy:                1.26.4
openpyxl:             <not installed>
pandas:               2.2.2
pyarrow:              15.0.2
pydantic:             <not installed>
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@niccolopetti
Copy link

This issue can be closed after #17628

@MarcoGorelli
Copy link
Collaborator Author

yup thanks!

@github-project-automation github-project-automation bot moved this from Ready to Done in Backlog Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-interop-pandas Area: interoperability with pandas bug Something isn't working P-low Priority: low python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants