I am trying to convert this dict to a DataFrame
My Json dict = {'comments': "['a','b','c']"}
My code:
contents = open('comments.json', "r").read()
json_obj = json.loads(contents)
pd.DataFrame.from_dict(json_obj)
It gave me this error : ValueError: If using all scalar values, you must pass an index
so I tried this:
pd.DataFrame.from_dict(json_obj)
Which gave me this df:
I need each item of this list to be in a row.
What I tried:
d = pd.DataFrame.from_dict([json_obj])
pd.DataFrame.from_records(d.comments)
But it split each letter to a column like this:
[![enter image description here][1]][1]
I also tried all the solutions related to this question but none of them work
Please note that my data is originally a list of arabic items and I dumped it to a file as a dictionary:
json.dump({'comments': tmp1},fp,indent = 4, ensure_ascii=False)
I don't understand what is going on and will appreciate any help!