Home > front end >  How to import JSON by pandas from data.world?
How to import JSON by pandas from data.world?

Time:10-18

I am new to this and have no idea why my code doesn't work. I want to read json data from: https://data.world/cnoza/cryptocurrencies I've tried it by link:

import pandas as pd
df = pd.read_json('https://query.data.world/s/tcjtnx4d2kjaujslprdlgnr72wwoue')

And also tried uploading the file:

df = pd.read_json("EUR.json")

Some kind of error occurs

ValueError: Mixing dicts with non-Series may lead to ambiguous ordering.

Thanks! Thanks to @Chris Happy for the clue
The solution that helped me:

import json
with open('EUR.json') as data_file:    
    data = json.load(data_file)

df = pd.json_normalize(data, record_path = ["data"])

CodePudding user response:

Pandas only handles JSON in a 2D format, but the cryptocurrency data is in a multi-dimensional form.

  • Related