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

DataFrame.group_by.head fails with Decimal types. #15330

Closed
2 tasks done
sernst opened this issue Mar 27, 2024 · 1 comment · Fixed by #15417
Closed
2 tasks done

DataFrame.group_by.head fails with Decimal types. #15330

sernst opened this issue Mar 27, 2024 · 1 comment · Fixed by #15417
Labels
A-dtype-decimal Area: decimal data type A-panic Area: code that results in panic exceptions bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@sernst
Copy link

sernst commented Mar 27, 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

df = (
    pl.DataFrame({
        "a": [1, 2, 3], 
        "b": ["1.123", "2.234", "3.345"]
    })
    # Comment out the decimal conversion and the code works. Only errors when b is Decimal dtype.
    .with_columns(pl.col("b").str.to_decimal())
    .group_by("a")
    .head(1)
)

Log output

thread 'polars-0' panicked at crates/polars-core/src/series/series_trait.rs:82:13:
`explode_by_offsets` operation not supported for dtype `decimal[*,3]`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "../site-packages/polars/dataframe/group_by.py", line 376, in head
    .collect(no_optimization=True)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "../site-packages/polars/lazyframe/frame.py", line 1943, in collect
    return wrap_df(ldf.collect())
                   ^^^^^^^^^^^^^
pyo3_runtime.PanicException: `explode_by_offsets` operation not supported for dtype `decimal[*,3]`

Issue description

I've tested this on both Linux (Ubuntu 22.04) and Windows and it fails with the same behavior.

Expected behavior

I would expect the head to work in the same fashion as in the case where the "b" column is a string type instead of a decimal type.

Installed versions

--------Version info---------
Polars:               0.20.16
Index type:           UInt32
Platform:             Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
Python:               3.12.2 (main, Feb 25 2024, 16:35:05) [GCC 11.4.0]

----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:               <not installed>
matplotlib:           <not installed>
numpy:                <not installed>
openpyxl:             <not installed>
pandas:               <not installed>
pyarrow:              <not installed>
pydantic:             <not installed>
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
--------Version info---------
Polars:               0.20.16
Index type:           UInt32
Platform:             Windows-11-10.0.22000-SP0
Python:               3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               2024.3.1
gevent:               <not installed>
hvplot:               <not installed>
matplotlib:           3.8.3
numpy:                1.26.4
openpyxl:             3.1.2
pandas:               2.2.1
pyarrow:              15.0.2
pydantic:             <not installed>
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@sernst sernst added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Mar 27, 2024
@stinodego stinodego added A-dtype-decimal Area: decimal data type A-panic Area: code that results in panic exceptions labels Mar 27, 2024
@stinodego
Copy link
Member

Looks like this hasn't been implemented yet. An implementation is welcome.

@stinodego stinodego added P-low Priority: low and removed needs triage Awaiting prioritization by a maintainer labels Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dtype-decimal Area: decimal data type A-panic Area: code that results in panic exceptions 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