I want to read a JSON file generated from a dict()
such that I can then make a pie chart. My code so far:
import json
import pandas as pd
openJson = open("path")
jsonFile = json.load(openJson)
df = pd.DataFrame.from_dict(jsonFile)
The problem I have is that I can't even try plotting the graph because I cant convert the JSON to a data frame. The error I get is ValueError: If using all scalar values, you must pass an index
. I also tried writing df = pd.DataFrame.from_dict(jsonFile, index=[0])
as found in a similar post, but it seems that index
is an unexpected argument.
How can I read that JSON so it can be plotted?
LE: Added JSON file called category.json
{"Restaurants": 678.7800000000001, "Utilities": 807.26, "Services": 35.67, "Transport": 1295.65, "Shopping": 1454.15, "Groceries": 1162.89}