feature request: make graph_objects also dataframe agnostic
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 18.8k
- Forks
- 2.8k
- Ø Merge
- 16 Std. 26 Min.
- Gemergte PRs (30 T.)
- 21
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das bereitgestellte polars-Beispiel über die graph_objects-API nachzustellen, mit Schwerpunkt auf go.Figure.add_trace mit Scatter und Bar. Untersuche, wie ihre Argumente x, y und marker_color derzeit Listen, NumPy-Arrays und pandas Series verarbeiten. Als erledigt gilt die Aufgabe, wenn die relevanten graph_objects-Trace-Argumente polars- und Arrow-Serien über narwhals akzeptieren, ohne eine Konvertierung zu erfordern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- data-visualization
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100