I have data as such
time close
date
6/1/20 00:00 4375.5
6/1/20 00:15 4374.0
6/1/20 00:30 4376.5
...
I used df.pivot(columns='time', values='close') to output this (which worked as I wanted)
00:00 00:15 00:30
date
6/1/20 4375.5 4374.0 4376.5
...
I ran the pct change across timeframes df.pct_change(axis=1)
00:00 00:15 00:30
date
6/1/20 NaN .00312 .00123 #these are just not real calcs, just putting in nums for example
...
Now I want to melt the df, but I'm having trouble doing so. I want the dataframe to go back to the original layout
time pct_change
date
6/1/20 00:00 NaN
6/1/20 00:15 .00312
6/1/20 00:30 .00123
...
The reason I want to do this is because plotly.express.density_heatmap() cannot read the data as in the non-melted form. I'm using streamlit and wanted to insert a chart with plotly but ultimatly the chart just needs to look the same as df.style.background_gradient(cmap='green')
from plotly.express as px
#this code doesnt work, but this is how ideally want to input it.
fig = px.density_heatmap(df, x='time', y='date', z='pct_change')
Thank you to anyone who provides guidance!