I'm using Jupyter notebook that is drawing a bar chart in offline mode without issues.
I have a Pandas dataframe from reading in a CSV file and I want to quickly create a pie chart in Plotly (offline mode).
Plotly pie chart values (https://plot.ly/python/reference/#pie-values) counts the labels if omitted. That's what I had hoped for. I wanted to set the pie chart labels (https://plot.ly/python/reference/#pie-labels) directly from my pandas dataframe.
My code:
import plotly as py
import plotly.graph_objs as go
import pandas as pd
from plotly.offline import init_notebook_mode
init_notebook_mode()
df2 = pd.read_csv("./testdata.csv")
trace = go.Pie(
labels= df2["Vendor"]
)
py.offline.plot(trace, filename='pdq_pie_chart.html')
I get an error when attempting this:
PlotlyError: The `figure_or_data` positional argument must be `dict`-like, `list`-like, or an instance of plotly.graph_objs.Figure
Did I miss something in the lead up to the go.Pie call? I deliberately didn't get into any formatting options, and wanted to generate the pie chart with as little code as possible from the dataframe.
labels= df2["Vendor"].values?