にデータを書き込む必要がありjson
ますが、文字列内のデータが昇順になるようにしたいです。しかし、私は得る
"0987654321abcdef1234567890abcdef": {
"2014-06": 1,
"2016-05": 1,
"2016-09": 1,
"2016-03": 0,
"2015-02": 0,
"2016-01": 0
}
しかし、私は使用してデータをソートしdf.sort_values(['ID', 'date'])
、書き込みます
nielson = StringIO.StringIO()
output.groupby('ID').apply(lambda x: x.set_index('filtered_dates')['val'].to_dict()).to_json(nielson, orient='index')
with open('nielsen','w') as f:
json.dump(json.loads(nielson.getvalue()), f, indent=2)