feature request: make graph_objects also dataframe agnostic
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 18.8k
- 分支
- 2.8k
- 平均合併
- 16 小時 26 分鐘
- 30 天內合併 PR
- 21
描述
I was wondering, since narwhals was such a success in the plotly express api, whether the graph_objects api could get the same treatment. For the few trace types I tried (Scatter, Bar), arguments such as x, y, marker_color etc., accept tuple, list, numpy array, or pandas Series.
It would be great to be able to pass arrow or polars series as well, via narwhals, though I have no idea how feasible that would really be.
Desired outcome would be something like this:
"""
Fresh environment
>>> uv init
>>> uv add plotly polars
"""
import plotly.graph_objects as go
import polars as pl
df = pl.DataFrame({"x": [0, 1, 2, 3, 4], "y": [0, 1, 4, 9, 16]})
fig = go.Figure()
fig.add_trace(
go.Scatter(x=df["x"], y=df["y"]),
)
fig.show()
Currently one has to either transform to a list, pandas series, or if numpy is installed, there is some implicit transformation, which allows to pass polars series directly.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先透過 graph_objects API 重現提供的 polars 範例,重點關注使用 Scatter 和 Bar 的 go.Figure.add_trace。檢查其 x、y 和 marker_color 引數目前如何處理列表、NumPy 陣列和 pandas Series。當相關的 graph_objects trace 引數能夠透過 narwhals 接受 polars 和 Arrow series,而不需要轉換時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- data-visualization
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100