Is there a way to visualize a time series data frame on Altair where variables are headers?

Viewed 63

I have to following data frame, that I want to visualize as a simple time series chart, but I can't find the way to plot it since my variables are in the header. Do you guys have any idea of how can I solve this?

This is my data frame:

enter image description here

1 Answers

You have what the Altair docs call wide-form data; Altair works best with long-form data. To work with your wide-form data, you can either preprocess the data and reshape it using the melt() function in Pandas, or you can transform it in the renderer using transform_fold() within the Altair chart specification.

For more information and some examples, see Specifying Data in Altair: Long-form vs. Wide-form data.

Related