has2k1 / plotnine

A Grammar of Graphics for Python
https://plotnine.org
MIT License
3.92k stars 210 forks source link

How to handle data that is not in long-format? #747

Closed fhg-isi closed 5 months ago

fhg-isi commented 5 months ago

Altair provides some transformations to work with data that is not in long format: https://altair-viz.github.io/user_guide/data.html#converting-with-fold-transform

=> Does plotnine provide similar features? Or do I have to pre-process my data, (for example with pd.melt(...) ) to be able to use plotnine?

Related:

https://stackoverflow.com/questions/77993663/how-to-create-stacked-bar-chart-from-different-data-format-with-altair-in-python

TyberiusPrime commented 5 months ago

Plotnine, like it's API donor ggplot2, is indeed requiring your data in long format.

Pandas.melt would be the way to go for most data sets - I personally don't see value in wrapping this operation in yet another level of abstraction / nomenclature (fold vs melt).

fhg-isi commented 5 months ago

Thank you for clarification.