Skip to content

Polars Pivot --aggregate flag Error #17524

@paul-d-ray

Description

@paul-d-ray

Bug report form

  • I have done a basic search of the issue tracker to find any existing issues that are similar.
  • I have checked that my version is at least the latest stable release available via my installation method.

Describe the bug

I am trying to create a polars pivot table and get an error.

Why is Nushell, 0.110, complaining about this?
Is my syntax incorrect?
The docs / help do not show an example of using the --aggregate flag.

× Pivot error: explicit column references are not allowed in aggregate_function
    ╭─[entry #195:19:5]
 18 │ $df |
 19 │     polars pivot --on [Year] --index [Auto] --values [Amount] --aggregate sum
    ·     ────────────
 20 │

How to reproduce

I have a csv file that has columns:

╭───┬──────────╮
│ 0 │ Num      │
│ 1 │ Date     │
│ 2 │ Payee    │
│ 3 │ Category │
│ 4 │ Amount   │
│ 5 │ Year     │
│ 6 │ Yearmon  │
│ 7 │ Auto     │
│ 8 │ Work     │
╰───┴──────────╯

Expected behavior

I would expect a pivot table something like this:
This was created using just nushell code.

╭───┬──────────────────────────┬───────┬──────┬───────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────╮
│ # │           Auto           │ Total │ 2026 │ 2025  │ 2024 │ 2023 │ 2022 │ 2021 │ 2020 │ 2019 │ 2018 │ 2017 │ 2016 │ 2015 │
├───┼──────────────────────────┼───────┼──────┼───────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
│ 0 │ 2014 Nissan Altima       │ 14800 │  105 │  8731 │ 1655 │  990 │   60 │   28 │ 3231 │  ❎  │  ❎  │  ❎  │  ❎  │  ❎  │
│ 1 │ 2012 Lexus RX 350        │  7868 │  127 │  3235 │ 2525 │ 1469 │   72 │  440 │  ❎  │  ❎  │  ❎  │  ❎  │  ❎  │  ❎  │
│ 2 │ 2011 Honda Civic         │  2305 │   84 │  ❎   │  422 │   22 │  ❎  │  ❎  │ 1777 │  ❎  │  ❎  │  ❎  │  ❎  │  ❎  │
│ 3 │ 2004 Chevrolet Silverado │ 15519 │  ❎  │  4336 │  ❎  │  659 │   72 │  ❎  │  166 │ 5141 │ 5145 │  ❎  │  ❎  │  ❎  │
│ 4 │ 2003 Jeep Liberty        │  6259 │  ❎  │  ❎   │  ❎  │  ❎  │  ❎  │  ❎  │  ❎  │  ❎  │ 1469 │ 1488 │ 2579 │  723 │
│ 5 │ 1999 Dodge Intrepid      │  1185 │  ❎  │  ❎   │  ❎  │  ❎  │  ❎  │  ❎  │  ❎  │  ❎  │  ❎  │  ❎  │  ❎  │ 1185 │
│ 6 │ TOTAL                    │ 47936 │  316 │ 16302 │ 4602 │ 3140 │  204 │  468 │ 5174 │ 5141 │ 6614 │ 1488 │ 2579 │ 1908 │
╰───┴──────────────────────────┴───────┴──────┴───────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯

Configuration

key value
version 0.110.0
major 0
minor 110
patch 0
branch
commit_hash d40e191
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.90.0 (1159e78c4 2025-09-14)
rust_channel 1.90.0-x86_64-pc-windows-msvc
cargo_version cargo 1.90.0 (840b83a10 2025-07-30)
build_time 2026-01-18 02:12:43 +00:00
build_rust_channel release
allocator standard
features default, mcp, network, plugin, rustls-tls, sqlite, trash-support
installed_plugins formats 0.109.1, polars 0.109.1, query 0.109.1
experimental_options example=false, reorder-cell-paths=true, pipefail=false, enforce-runtime-annotations=false

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:needs-triageAn issue that hasn't had any proper look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions