In Python how to plot pie chart using plotly

I am trying to plot using plotly. I am using the go command. I can design bar charts, but when I am trying pie using the go command. I got error ValueError at / Invalid property specified for object of type plotly.graph_objs.Pie: 'x'

I am sharing here my code . I want to convert a bar graph into a pie.

df2 = df.groupby(pd.to_datetime(df.MeterReading_DateTime).dt.hour).agg({'ACT_IMP_TOT': 'sum'}).reset_index()

print(df2)
#x = df2['MeterReading_DateTime']
#y = df2['ACT_IMP_TOT']
data_plots = go.Bar(x=df2['MeterReading_DateTime'], y= df2['ACT_IMP_TOT'],marker = {'color' : '#0f4054'})
#data_plots = px.pie(values=random_x, names=names) 
layout = {'title': '','xaxis': {'title': 'Date and time'},'yaxis': {'title': 'Total Import(KWH)'},'plot_bgcolor':'#E8E8E8'}
fig = {'data': data_plots, 'layout': layout}
plot_div = offline.plot(fig, output_type='div')
return plot_div
Back to Top