【发布时间】:2018-04-05 06:46:28
【问题描述】:
我对 python 完全陌生。我需要一点帮助才能过滤我的 JSON。
json = {
"selection":[
{
"person_id":105894,
"position_id":1,
"label":"Work",
"description":"A description",
"startDate":"2017-07-16T19:20:30+01:00",
"stopDate":"2017-07-16T20:20:30+01:00"
},
{
"person_id":945123,
"position_id":null,
"label":"Illness",
"description":"A description",
"startDate":"2017-07-17T19:20:30+01:00",
"stopDate":"2017-07-17T20:20:30+01:00"
}
]
}
具体来说,我要做的是将我的 JSON(在上面)转换为 Dataframe,以便能够在其上使用查询方法,例如:
selected_person_id = 105894
query_person_id = json[(json['person_id'] == selected_person_id)]
or
json.query('person_id <= 105894')
列必须是:
cols = ['person_id', 'position_id', 'label', 'description', 'startDate', 'stopDate']
我该怎么做?
【问题讨论】: