I am trying to generate a plotly bar chart out of a grouped df. I have the data ordered by the groupby python statement. The data is arranged appropriately but I can't generate the plotly bar chart.
python is giving a value error ValueError: Value of 'x' is not the name of a column in 'data_frame'. Expected one of ['amount'] but received: Issued_Date
Additionally I would like the bar chart to be stacked. For example , row 0 and row 5 are the same date so i would like to have stacked bars
df_A = df_pre.groupby(['Transaction','Type'])["amount"].resample('M').sum().to_frame('amount')
fig = px.bar(df_A, x='Issued_Date', y='amount', color='Type',
title='Timeseries amount',
barmode='group',
height=600
)
fig.show()
df_A.to_dict('split')
{'index': [('No', 'B', Timestamp('2019-03-31 00:00:00')),
('No', 'E', Timestamp('2018-10-31 00:00:00')),
('No', 'H', Timestamp('2019-07-31 00:00:00')),
('So', 'B', Timestamp('2018-12-31 00:00:00')),
('So', 'E', Timestamp('2018-12-31 00:00:00')),
('So', 'H', Timestamp('2019-03-31 00:00:00')),
('So', 'H', Timestamp('2019-05-31 00:00:00')),
('So', 'H', Timestamp('2019-06-30 00:00:00')),
('So', 'H', Timestamp('2019-07-31 00:00:00'))],
'columns': ['amount'],
'data': [[39.21],
[64.49],
[572.78],
[13.46],
[44.54],
[13.96],
[0.0],
[46.76],
[13.28]]}
dfA
? Or something else? – vestland