我有我已經從具有6個鍵一個JSON URL中提取的字典。我的興趣只在'value'
的關鍵值。該數據的結構是這樣的:提取密鑰,從字典值作爲數據幀
[in] print(data)
[out] ...'values': [{'x': 1230940800, 'y': 0},
{'x': 1231113600, 'y': 0},
{'x': 1231286400, 'y': 0},
{'x': 1231459200, 'y': 0},
{'x': 1231632000, 'y': 0},
{'x': 1231804800, 'y': 0},
{'x': 1231977600, 'y': 0},
{'x': 1232150400, 'y': 0},
{'x': 1232323200, 'y': 0},
{'x': 1232496000, 'y': 0},
{'x': 1232668800, 'y': 0},
{'x': 1232841600, 'y': 0},
{'x': 1233014400, 'y': 0},
{'x': 1233187200, 'y': 0},
{'x': 1233360000, 'y': 0}]
哪裏'x'
是Unix時間戳和'y'
是當時的價值。 我怎麼能提取從'value'
字典中的值,並重新調整他們,使'x'
標記爲'date'
和結構化的格式爲:2011-09-13
?
'btc_usd2 = pd.DataFrame({ '日期':np.array([subdct [ 'X']用於btc_usd1 subdct],D型細胞= 'datetime64 [s]的'), 'Y':[subdct ['Y '] for subdct in btc_usd1]})'TypeError:字符串索引必須是整數 – zsad512
'btc_usd = json.loads(url.read()。decode()) btc_usd1 = pd.DataFrame(btc_usd)'在代碼之前剛剛複製 – zsad512
我並不是說你應該使用'DataFrame'作爲'lst'變量。然後我的代碼運行 - 如果你使用'LST = btc_usd [ '值']'(而不是'btc_usd1'!從'btc_usd')會發生什麼? – MSeifert