Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭 适合新手
#5,769 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
65/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
活跃
技术栈
python

调研方向

阅读 plotly/express/_core.py 中的 process_dataframe_hierarchy,并确认最低版本的 narwhals 在 group_by 上提供 maintain_order。使用 test_sunburst_treemap_with_path_order 作为回归检查;完成的标准是临时排序机制已移除、测试仍然通过,并且基于路径的 sunburst、treemap 和 icicle 排序仍保持确定性。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
18.8k
派生
2.8k
平均合并
13 小时 41 分钟
30 天内合并 PR
21

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

plotly/plotly.py 的其他 Issue

查看 plotly/plotly.py 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。