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

melt panics when id_vars is a non-existing column #13493

Open
2 tasks done
stinodego opened this issue Jan 6, 2024 · 0 comments · May be fixed by #15514
Open
2 tasks done

melt panics when id_vars is a non-existing column #13493

stinodego opened this issue Jan 6, 2024 · 0 comments · May be fixed by #15514
Labels
bug Something isn't working P-medium Priority: medium python Related to Python Polars

Comments

@stinodego
Copy link
Member

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

import polars as pl

df = (
    pl.DataFrame({"col0": [0], "col1": ["a"], "col2": ["b"]})
    .lazy()
    .melt(id_vars="row_nr")
    .collect()
)
# pyo3_runtime.PanicException: called `Option::unwrap()` on a `None` value

Log output

thread '<unnamed>' panicked at crates/polars-plan/src/logical_plan/builder_functions.rs:22:55:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/home/stijn/code/polars/py-polars/repro.py", line 6, in <module>
    .melt(id_vars="row_nr")
     ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stijn/code/polars/py-polars/polars/lazyframe/frame.py", line 5409, in melt
    self._ldf.melt(id_vars, value_vars, value_name, variable_name, streamable)
pyo3_runtime.PanicException: called `Option::unwrap()` on a `None` value

Issue description

In lazy mode this panics. In eager mode, this returns a somewhat sensible error:

polars.exceptions.SchemaFieldNotFoundError: row_nr

Expected behavior

Throw a proper error.

Installed versions

main branch

@stinodego stinodego added bug Something isn't working python Related to Python Polars accepted Ready for implementation labels Jan 6, 2024
@ritchie46 ritchie46 added the P-medium Priority: medium label Jan 7, 2024
@stinodego stinodego removed the accepted Ready for implementation label Jan 12, 2024
@edavisau edavisau linked a pull request Apr 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-medium Priority: medium python Related to Python Polars
Projects
Status: Ready
Development

Successfully merging a pull request may close this issue.

2 participants