📜  从 json 格式的列中提取值 python - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:53.278000             🧑  作者: Mango

代码示例1
import pandas as pd

d1 = '{"605":{"price":"570", "address":"946", "status": "done", "#result":"good" }}'
d2 = '{"254":{"price":"670", "address":"300", "status": "done", "classification_id": "102312321", "#result":"good" }}'

df = pd.DataFrame({'num': [1771, 905],
                  'item': ['orange', 'mango'],
                  'id': [190384, 2500003],
                  'data':[d1, d2],
                  'reg': [605, 254]
    })


import json
df = df.join( pd.DataFrame(list(json.loads(d).values())[0] for d in df.pop('data')) )

# drop columns we don't want
del df['address']
del df['classification_id']

print(df)