我试过下面的代码
Click on this link to get the json file
进口Pandas当PD
df = pd.read_json('C:\\Users\\rajat.kapoor\\Downloads\\comprehensive JSON.json')
df.to_excel('C:\\Users\\rajat.kapoor\\Desktop\\JsonOutput.xlsx')
但它正在给予
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\internals\construction.py:666, in _extract_index(data)
664 lengths = list(set(raw_lengths))
665 if len(lengths) > 1:
--> 666 raise ValueError("All arrays must be of the same length")
668 if have_dicts:
669 raise ValueError(
670 "Mixing dicts with non-Series may lead to ambiguous ordering."
671 )
ValueError: All arrays must be of the same length
我已经检查了许多关于这个ValueError的帖子,但超出了我的理解范围。希望能为此提供解决方案
1条答案
按热度按时间7eumitmz1#
您可以使用
pd.json_normalize
: