I need to convert a data frame query into a dictionary variable but it is saving the STATE and Occurrences as one variable. I need them separate so I can plot a bar chart from it Am I doing it wrong?
Code for dataframe to dict
df = pd.DataFrame(data_dict)
df = df['xyz'].value_counts().to_frame()
df.to_dict('dict')
print (dict)
Code i want to use to plot my bar chart
data = (dict)
names = list(data.keys())
values = list(data.values())
plt.bar(range(len(data)),values,tick_label=names)
plt.show()