我正在尝试使用API提取一些数据,但输出似乎是列表的字典。
使用下面的示例JSON对象,我需要提取键(即股票行情自动收录器)和值(即'chart'元素内的数据)。
最终,我将其传递到一个DataFrame中,其中股票行情指标值为1列,图表元素中的每个项目为15列,每个股票行情为5行。
有人有任何技巧来做到这一点吗?
{'AAPL': {'chart': [{'change': 0,
'changeOverTime': 0,
'changePercent': 0,
'close': 118.64,
'date': '2020-11-19',
'high': 119.06,
'label': 'Nov 19',
'low': 116.81,
'open': 117.59,
'uClose': 118.64,
'uHigh': 119.06,
'uLow': 116.81,
'uOpen': 117.59,
'uVolume': 74112972,
'volume': 74112972},
{'change': -1.3,
'changeOverTime': -0.010958,
'changePercent': -1.0958,
'close': 117.34,
'date': '2020-11-20',
'high': 118.77,
'label': 'Nov 20',
'low': 117.29,
'open': 118.64,
'uClose': 117.34,
'uHigh': 118.77,
'uLow': 117.29,
'uOpen': 118.64,
'uVolume': 73604287,
'volume': 73604287},
{'change': -3.49,
'changeOverTime': -0.040374,
'changePercent': -2.9743,
'close': 113.85,
'date': '2020-11-23',
'high': 117.62,
'label': 'Nov 23',
'low': 113.75,
'open': 117.18,
'uClose': 113.85,
'uHigh': 117.62,
'uLow': 113.75,
'uOpen': 117.18,
'uVolume': 127959318,
'volume': 127959318},
{'change': 1.32,
'changeOverTime': -0.029248,
'changePercent': 1.1594,
'close': 115.17,
'date': '2020-11-24',
'high': 115.85,
'label': 'Nov 24',
'low': 112.59,
'open': 113.91,
'uClose': 115.17,
'uHigh': 115.85,
'uLow': 112.59,
'uOpen': 113.91,
'uVolume': 113874218,
'volume': 113874218},
{'change': 0.86,
'changeOverTime': -0.021999,
'changePercent': 0.7467,
'close': 116.03,
'date': '2020-11-25',
'high': 116.75,
'label': 'Nov 25',
'low': 115.17,
'open': 115.55,
'uClose': 116.03,
'uHigh': 116.75,
'uLow': 115.17,
'uOpen': 115.55,
'uVolume': 76499234,
'volume': 76499234}]},
'MSFT': {'chart': [{'change': 0,
'changeOverTime': 0,
'changePercent': 0,
'close': 212.42,
'date': '2020-11-19',
'high': 213.03,
'label': 'Nov 19',
'low': 209.93,
'open': 211.38,
'uClose': 212.42,
'uHigh': 213.03,
'uLow': 209.93,
'uOpen': 211.38,
'uVolume': 24792746,
'volume': 24792746},
{'change': -2.03,
'changeOverTime': -0.009557,
'changePercent': -0.9557,
'close': 210.39,
'date': '2020-11-20',
'high': 213.29,
'label': 'Nov 20',
'low': 210,
'open': 212.2,
'uClose': 210.39,
'uHigh': 213.29,
'uLow': 210,
'uOpen': 212.2,
'uVolume': 22843119,
'volume': 22843119},
{'change': -0.28,
'changeOverTime': -0.010875,
'changePercent': -0.1331,
'close': 210.11,
'date': '2020-11-23',
'high': 212.29,
'label': 'Nov 23',
'low': 208.16,
'open': 210.95,
'uClose': 210.11,
'uHigh': 212.29,
'uLow': 208.16,
'uOpen': 210.95,
'uVolume': 25683507,
'volume': 25683507},
{'change': 3.75,
'changeOverTime': 0.006779,
'changePercent': 1.7848,
'close': 213.86,
'date': '2020-11-24',
'high': 214.25,
'label': 'Nov 24',
'low': 208.86,
'open': 209.59,
'uClose': 213.86,
'uHigh': 214.25,
'uLow': 208.86,
'uOpen': 209.59,
'uVolume': 33979731,
'volume': 33979731},
{'change': 0.01,
'changeOverTime': 0.006826,
'changePercent': 0.0047,
'close': 213.87,
'date': '2020-11-25',
'high': 215.29,
'label': 'Nov 25',
'low': 212.46,
'open': 215.11,
'uClose': 213.87,
'uHigh': 215.29,
'uLow': 212.46,
'uOpen': 215.11,
'uVolume': 21012887,
'volume': 21012887}]}}