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

Expr.hist / Series.hist call fails on empty Series #14207

Closed
2 tasks done
codesorcery opened this issue Feb 2, 2024 · 1 comment · Fixed by #14407
Closed
2 tasks done

Expr.hist / Series.hist call fails on empty Series #14207

codesorcery opened this issue Feb 2, 2024 · 1 comment · Fixed by #14407
Labels
bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@codesorcery
Copy link

codesorcery commented Feb 2, 2024

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

pl.Series("a", [None, None, None], dtype=pl.Float32).hist()

Log output

thread '<unnamed>' panicked at crates/polars-ops/src/chunked_array/hist.rs:71:37:
called `Option::unwrap()` on a `None` value

Issue description

Calling Expr.hist / Series.hist on an empty series fails with an error in the corresponding Rust code.
The problematic part in the Rust code is that ChunkAgg::min(ca) and ChunkAgg::max(ca) return None, which is then unwrapped without proper None check handling.

Expected behavior

Return an empty table with the same schema as when Expr.hist / Series.hist is called on non-empty series.

Installed versions

--------Version info---------
Polars:               0.20.6
Index type:           UInt32
Platform:             Linux-5.15.142-flatcar-x86_64-with-glibc2.36
Python:               3.11.6 | packaged by conda-forge | (main, Oct  3 2023, 10:40:35) [GCC 12.3.0]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          2.2.1
connectorx:           <not installed>
deltalake:            0.15.1
fsspec:               2023.9.2
gevent:               <not installed>
hvplot:               <not installed>
matplotlib:           3.7.3
numpy:                1.24.4
openpyxl:             <not installed>
pandas:               2.0.3
pyarrow:              13.0.0
pydantic:             2.4.2
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           2.0.23
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@codesorcery codesorcery added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Feb 2, 2024
@reswqa reswqa added P-low Priority: low and removed needs triage Awaiting prioritization by a maintainer labels Feb 2, 2024
@codesorcery
Copy link
Author

Thanks, @lukemanley and @ritchie46 !

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-low Priority: low python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants