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

Unable to cast u8 to enum #15729

Closed
2 tasks done
neeldugar opened this issue Apr 18, 2024 · 1 comment
Closed
2 tasks done

Unable to cast u8 to enum #15729

neeldugar opened this issue Apr 18, 2024 · 1 comment
Labels
A-dtype-categorical Area: categorical data type bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@neeldugar
Copy link

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({
    "a": [0, 1, 2, 3, 4]
}, schema={"a": pl.UInt8})

dtype = pl.Enum(["et1", "et2", "et3", "et4", "et5"])
df = df.select([
    pl.col("a").cast(dtype),
])
print(df)

Log output

thread '' panicked at /Users/runner/work/polars/polars/crates/polars-arrow/src/array/binview/mod.rs:256:9:
assertion failed: i < self.len()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
...
pyo3_runtime.PanicException: assertion failed: i < self.len()

Issue description

Probably follows from #13409 and #13955 respectively

Expected behavior

No Rust exception to get thrown & valid cast to occur if elements all fall within enum range.

Installed versions

--------Version info---------
Polars:               0.20.21
Index type:           UInt32
Platform:             macOS-13.6.5-arm64-arm-64bit
Python:               3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.1.0.2.5)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               <not installed>
gevent:               <not installed>
hvplot:               0.9.2
matplotlib:           <not installed>
nest_asyncio:         <not installed>
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>
@neeldugar neeldugar added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Apr 18, 2024
@stinodego stinodego added the A-dtype-categorical Area: categorical data type label Apr 18, 2024
@reswqa
Copy link
Collaborator

reswqa commented Apr 18, 2024

Thanks! This should be completely covered by #15738, I will close this and in favor of that one.

@reswqa reswqa closed this as completed Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dtype-categorical Area: categorical data type bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

3 participants