My original dataframe contains hourly data from several entities.sample(5) of original dataframe
I have used pd.pivot_table with index=pd.Grouper(freq='M') to obtain the sum of the value for each entity grouped by Month.
piv=pd.pivot_table(df, values='EnergyValue',index=pd.Grouper(freq='M', key='DDMM'),columns=['entityID'], aggfunc=np.sum)
I now want to plot this using plotly. example of dataframe after pivot_table
I am able to plot the pivot_table directly by adding .plot()
pd.pivot_table(df, values='EnergyValue',index=pd.Grouper(freq='M', key='DDMM'),columns=['entityID'], aggfunc=np.sum).plot()
.plot() directly after pivot_table operation on dataframe
However I want this chart to be in plotly. I have tried to stack the pivot_table and then plot. dataframe after stack operation. I want to plot the values column (red arrow) as y-value and index as x-value
However, I am not able to use the value as y-axis How do I access this y-value?
stack=piv.stack()
px.line(stack,x='DDMM',y=piv.values,color='entityID')
yargument only accepts names of columns of the data frame argument at the moment. - nicolaskruchten