下面是数据框
df = pd.DataFrame([['xxx xxx','specs','67646546','TEST 123','United States of America']], columns = ['name', 'type', 'aim', 'aimd','context' ])
我正在尝试在“数据”下添加对象“ aimd”。 下面是格式
{
"entities": [{
"name": "xxx xxx",
"type": "specs",
"data": {
"attributes": {
"aimd": {
"values": [{
"value": "xxxxx",
"source": "internal",
"locale": "en_Us"
}
]
}
},
"contexts": [{
"attributes": {
"aim": {
"values": [{
"value": "67646546",
"source": "internal",
"locale": "en_Us"
}
]
}
},
"context": {
"country": "United States of America"
}
}
]
}
}
]
}
答案 0 :(得分:1)
只需插入一个附加数组即可。
270
输出:
"price": 275,
"promocodes" : [
{
"code" : "promo1",
"price" : 265.5
},
{
"code" : "promo2",
"price" : 270
},
{
"code" : "promo3",
"price" : 250
}
]