Skip to content

map_groups panic if function requires positional arguments #26647

@cmdlineluser

Description

@cmdlineluser

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.select(x=1).group_by("x").map_groups(lambda x, y: x)
# PanicException: UDF failed: <lambda>() missing 1 required positional argument: 'y'

Log output

thread '<unnamed>' (2397467) panicked at crates/polars-python/src/dataframe/general.rs:393:35:
UDF failed: <lambda>() missing 1 required positional argument: 'y'

Issue description

Called the wrong function by mistake.

Seems like it just needs to propagate the error instead of a panic.

Expected behavior

Error instead of panic.

Installed versions

Details
--------Version info---------
Polars:              1.38.1
Index type:          UInt32
Platform:            macOS-13.6.1-arm64-arm-64bit-Mach-O
Python:              3.13.3 (main, Apr  8 2025, 13:54:08) [Clang 15.0.0 (clang-1500.1.0.2.5)]
Runtime:             rt32

----Optional dependencies----
Azure CLI            <not installed>
adbc_driver_manager  1.10.0
altair               6.0.0
azure.identity       1.25.1
boto3                1.42.42
cloudpickle          3.1.2
connectorx           0.4.5
deltalake            1.4.2
fastexcel            0.19.0
fsspec               2026.2.0
gevent               25.9.1
google.auth          2.48.0
great_tables         0.20.0
matplotlib           3.10.8
numpy                2.3.5
openpyxl             3.1.5
pandas               3.0.0
polars_cloud         0.4.3
pyarrow              23.0.0
pydantic             2.12.5
pyiceberg            0.10.0
sqlalchemy           2.0.46
torch                <not installed>
xlsx2csv             0.8.6
xlsxwriter           3.2.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-panicArea: code that results in panic exceptionsbugSomething isn't workingneeds triageAwaiting prioritization by a maintainerpythonRelated to Python Polars

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions