我具有以下结构的JSON文件:
SELECT
s.sampleId,
s.color,
case when c.condition is null
then 'N'
else 'Y'
end condition23
FROM
samples s
LEFT JOIN conditions c
ON s.sampleId = c.sampleId
AND c.condition = 23
我正在用python程序加载它,如下所示:
{"0":"bla bla bla bla", "1":"bla bla bla bla", "2":"..."}
接下来,我想将其转换为import json
with open('./json/articles1.json') as json_file:
data = json.load(json_file)
。我都尝试过:
DataFrame
但是它们都产生错误df = pd.DataFrame(data)
df = pd.read_json(data)
答案 0 :(得分:0)
这对我有用
import json
import pandas as pd
with open('data.json') as json_file:
data = json.load(json_file)
df = pd.DataFrame(data, index=[0])
print(df)
此打印
0 1 2
0 bla bla bla bla bla bla bla bla ...