path = '/content/drive/MyDrive/gbd.json'
df = pd.read_json(path)
this is the error I am getting.
ValueError Traceback (most recent call last)
<ipython-input-11-3e269770844d> in <module>()
1 path = '/content/drive/MyDrive/gbd.json'
----> 2 df = pd.read_json(path)
6 frames
/usr/local/lib/python3.7/dist-packages/pandas/io/json/_json.py in _parse_no_numpy(self)
1138 if orient == "columns":
1139 self.obj = DataFrame(
-> 1140 loads(json, precise_float=self.precise_float), dtype=None
1141 )
1142 elif orient == "split":
ValueError: Expected object or value
我已经尝试过以下所有解决方案
data= pd.read_json('Data.json', lines=True)
data= pd.read_json('Data.json', lines=True, orient='records')
data= pd.read_json('Data.json', orient=str)
这是指向json文件https://ccewuksprdoneregsadata1.blob.core.windows.net/data/json/publicextract.charity.zip的链接,我想从json文件创建一个数据格式。
发布于 2022-02-02 07:01:10
文件的格式不太好。尝试:
with open('publicextract.charity.json', encoding='utf-8-sig') as fp:
data = json.loads(''.join(line.strip() for line in fp))
df = pd.json_normalize(data)
输出:
date_of_extract organisation_number registered_charity_number linked_charity_number charity_name ... cio_is_dissolved date_cio_dissolution_notice charity_activities charity_gift_aid charity_has_land
0 2022-02-02T00:00:00 1 200027 1 POTTERNE MISSION ROOM AND TRUST ... None None None None None
1 2022-02-02T00:00:00 2 200027 2 HITCHAM FREE CHURCH ... None None None None None
2 2022-02-02T00:00:00 3 200028 1 TOWN LANDS CHARITY FOR THE POOR ... None None None None None
3 2022-02-02T00:00:00 4 200028 2 TOWN LANDS CHARITY FOR THE CHURCH ... None None None None None
4 2022-02-02T00:00:00 5 200034 1 CLOPHILL RELIEF IN NEED CHARITY ... None None None None None
... ... ... ... ... ... ... ... ... ... ... ...
376732 2022-02-02T00:00:00 5193574 1197688 0 FEN DRAYTON PRIMARY SCHOOL PTA ... False None None None None
376733 2022-02-02T00:00:00 5193708 1197741 0 BOLSOVER C OF E JUNIOR SCHOOL FROG ... False None None None None
376734 2022-02-02T00:00:00 5193765 1197681 0 ST MICHAEL'S RC PRIMARY PTA ... False None None None None
376735 2022-02-02T00:00:00 5193830 1197732 0 THE LIGHTHOUSE, DARWEN ... False None None None None
376736 2022-02-02T00:00:00 5193998 1197750 0 THE PENDLE FOUNDATION ... False None None None None
[376737 rows x 34 columns]
https://stackoverflow.com/questions/70950854
复制相似问题