我有这个代码
eventSummary = {}
eventSummary['jobClassID'] = data['jobClassID'].split()
eventSummary['modelID'] =data['modelID'].split()
eventSummary['startDate'] = pd.to_datetime(start).date().strftime("%Y-%m-%d").split()
eventSummary['hourlySummary']=merged_df.to_json(orient = 'records')
dataF = pd.DataFrame(eventSummary)
dataF.to_json(path_or_buf = '*\merged2.json', orient="records")
这给了我这样的json:
{
"jobClassID":"NorthernRegion|FarNorthDistrict|GeneralDuties|Constable|FIR|Senior|Lead|5",
"modelID":"4",
"startDate":
"2019-01-01",
"hourlySummary":
"[{\"Day\":1,\"Hour\":0,\"Month\":1,\"priority\":3,\"Count\":3,\"Hourly Season\":1.5589041096,\"Weekly Season\":1.9205974843,\"Monthly Season\":2.0497311828,\"Noise Factor\":0.6517894485,\"groupId\":0,\"K (Service)\":0.6955185685,\"Theta (Service)\":10924.8330481261,\"K (Travel)\":0.6819906983,\"Theta (Travel)\":5694.9711557023}]
}
但我希望输出是这样的:{
"jobClassID":["NorthernRegion|FarNorthDistrict|GeneralDuties|Constable|FIR|Senior|Lead|5"],
"modelID":["4"],
"startDate":["2019-01-01"],
"hourlySummary":[
{"Day":1,"Hour":0,"Month":1,"priority":3,"Count":3,"Hourly Season":1.5589041096,"Weekly Season":1.9205974843,"Monthly Season":2.0497311828,"Noise Factor":0.6517894485,"groupId":0,"K (Service)":0.6955185685,"Theta (Service)":10924.8330481261,"K (Travel)":0.6819906983,"Theta (Travel)":5694.9711557023}]
}
如何做到这一点?
提前致谢。