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.int_range() panicks when dtype=pl.String, and is inconsistent with pl.int_ranges() #15307

Closed
2 tasks done
etiennebacher opened this issue Mar 26, 2024 · 1 comment · Fixed by #15339
Closed
2 tasks done
Assignees
Labels
A-input-parsing Area: parsing input arguments A-panic Area: code that results in panic exceptions accepted Ready for implementation bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@etiennebacher
Copy link
Contributor

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.int_range(0, 3, dtype=pl.String, eager=True)

thread '<unnamed>' panicked at py-polars\src\functions\eager.rs:104:15:
not implemented for dtype String
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\etienne\AppData\Roaming\Python\Python311\site-packages\polars\functions\range\int_range.py", line 218, in int_range
    return wrap_s(plr.eager_int_range(start, end, step, dtype))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyo3_runtime.PanicException: not implemented for dtype String

>>> pl.DataFrame({"start": [1, -1], "end": [3, 2]}).with_columns(
    int_ranges=pl.int_ranges("start", "end", dtype=pl.String)
)

shape: (2, 3)
┌───────┬─────┬──────────────────┐
│ startendint_ranges       │
│ ---------              │
│ i64i64list[str]        │
╞═══════╪═════╪══════════════════╡
│ 13   ┆ ["1", "2"]       │
│ -12   ┆ ["-1", "0", "1"] │
└───────┴─────┴──────────────────┘

Log output

No response

Issue description

pl.int_range() panicks with dtype=pl.String.

There's also a consistency issue since pl.int_ranges() casts the output to list[str].

Expected behavior

Not sure if both pl.int_range() and pl.int_ranges() should error or cast the output to str and list[str] respectively.

Installed versions

--------Version info---------
Polars:               0.20.16
Index type:           UInt32 
Platform:             Windows-10-10.0.19044-SP0
Python:               3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               2023.6.0
gevent:               <not installed>
hvplot:               0.9.2
matplotlib:           3.7.1
numpy:                1.24.3
openpyxl:             <not installed>
pandas:               2.0.3
pyarrow:              12.0.1
pydantic:             2.6.4
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@etiennebacher etiennebacher added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Mar 26, 2024
@stinodego stinodego added the P-low Priority: low label Mar 27, 2024
@github-project-automation github-project-automation bot moved this to Ready in Backlog Mar 27, 2024
@stinodego stinodego added A-input-parsing Area: parsing input arguments and removed needs triage Awaiting prioritization by a maintainer labels Mar 27, 2024
@stinodego
Copy link
Contributor

Both should error.

@stinodego stinodego added the A-panic Area: code that results in panic exceptions label Mar 27, 2024
@stinodego stinodego self-assigned this Mar 27, 2024
@github-project-automation github-project-automation bot moved this from Ready to Done in Backlog Mar 27, 2024
@c-peters c-peters added the accepted Ready for implementation label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-input-parsing Area: parsing input arguments A-panic Area: code that results in panic exceptions accepted Ready for implementation 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.

3 participants