Experts,
I am having issues parsing Json to Pandas and then save it in CSV format.
data2 = {"date":"2018-01-02","data":{"AAPL":{"open":"170.16","close":"172.26","high":"172.30","low":"169.26","volume":"25555934"},"MSFT":{"open":"86.13","close":"85.95","high":"86.31","low":"85.50","volume":"22483797"}}}
If I try :
df = pd.DataFrame.from_dict(json_normalize(data2), orient='columns')
print(df)
Everything gets printed in a single line :
If I do :
jdata = json.loads(data2)
df = pd.DataFrame(jdata)
print(df.T)
I get an error : TypeError: the JSON object must be str, bytes or bytearray, not 'dict'
I am looking to print it in the following table format so I can then save it as csv :
Date Data Open Close High Low Volume
2018-01-02 AAPL 170.16 172.26 172.30 169.26 25555934
2018-01-02 MSFT 86.13 85.95 86.31 85.50 22483797
What is the correct way to achieve my goal ?
Thanks !!
