Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Use group_by(maintain_order=True) in process_dataframe_hierarchy once narwhals exposes it

Open Beginner friendly
#5,769 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Read process_dataframe_hierarchy in plotly/express/_core.py and confirm the minimum narwhals version in pyproject.toml exposes maintain_order on group_by. Use test_sunburst_treemap_with_path_order as the regression check; done means the temporary ordering machinery is gone, the test still passes, and path-based sunburst, treemap, and icicle ordering remains deterministic.

Written by the indexing model from the issue text.

Description

P3 size: 1 task
Description

process_dataframe_hierarchy (plotly/express/_core.py), which builds the data for px.sunburst, px.treemap and px.icicle when path is used, adds a temporary row index column, aggregates its minimum per group and sorts each level by it. This is there only to get a deterministic sector order out of group_by, whose row order is not guaranteed for every backend (#5765, #5766).

narwhals is planning to expose maintain_order on group_by (narwhals-dev/narwhals#3309). Once that lands and the minimum supported narwhals version in pyproject.toml includes it, the temporary column, its aggregation and the per-level sort can be dropped in favour of df.group_by(path[i:], drop_null_keys=True, maintain_order=True).

The existing test_sunburst_treemap_with_path_order test covers the behaviour, so it should keep passing after the switch.

Filed as a follow up to #5766, as suggested by @camdecoster in #5765.

Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
13h 41m
Merged PRs (30d)
21

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from plotly/plotly.py

All issues in plotly/plotly.py

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.