I have an input json file that looks roughly like this
[
{
"identifier": "116S5RJ63",
"containers": [
{
"contains": "soap",
"height": {
"unit": "FT",
"value": 12.07123829231181
},
"length": {
"unit": "FT",
"value": 12.07123829231181
},
"quantity": 1,
"weight": {
"unit": "volumeUnits",
"value": 10000
},
"width": {
"unit": "FT",
"value": 12.07123829231181
}
}
],{...}]
I read it in using
input_json = pd.read_json(input_json_file)
I then process the input_json a bit: nothing dramatic, just changing the contents of some fields. Next I try to output the json again as
input_json.to_json(output_file, orient='records', date_format='iso')
but the output looks like this
[
{
"index": 28741,
"identifier": "115JKLJVZ",
"containers": [
{
"contains": "soap",
"height": {
"unit": "FT",
"value": 12.07123829231181
},
"length": {
"unit": "FT",
"value": 12.07123829231181
},
"quantity": 1,
"weight": {
"unit": "volumeUnits",
"value": 10000
},
"width": {
"unit": "FT",
"value": 12.07123829231181
}
}
],{...}]
Specifically it now includes the field 'index', which I thought the orient='records' was supposed to deal with. I'm not sure what to do next. Any suggestions?
question from:
https://stackoverflow.com/questions/65946445/how-can-i-generate-a-json-file-in-pandas-without-including-the-index 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…