3 回答
TA贡献1794条经验 获得超7个赞
data = {
"dataset": {
"id":42635350,"dataset_code":"MSFT",
"column_names": ["Date","Open","High","Low","Close","Volume","Dividend","Split","Adj_Open","Adj_High","Adj_Low","Adj_Close","Adj_Volume"],
"frequency":"daily",
"type":"Time Series",
"data":[
["2017-12-28",85.9,85.93,85.55,85.72,10594344.0,0.0,1.0,83.1976157998082, 83.22667201021558,82.85862667838872,83.0232785373639,10594344.0],
["2017-12-27",85.65,85.98,85.215,85.71,14678025.0,0.0,1.0,82.95548071308001,83.27509902756123,82.53416566217294,83.01359313389476,14678025.0]
]
}
}
下面的代码应该做你想做的吗?
import pandas as pd
df = pd.DataFrame(data, columns = data['dataset']['column_names'])
for i, data_row in enumerate(data['dataset']['data']):
df.loc[i] = data_row
TA贡献1783条经验 获得超4个赞
以下代码段应该适合您
import pandas as pd df = pd.DataFrame(data['dataset']['data'],columns=data['dataset']['column_names'])
检查以下链接以了解更多信息 https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html
TA贡献1824条经验 获得超6个赞
cols = data['dataset']['column_names']
data = data['dataset']['data']
这很简单
labeled_data = [dict(zip(cols, d)) for d in data]
添加回答
举报