I have a json file with the following structure
[
{
"name": "Collection 1",
"details": [
{
"id": 302,
"description":"Book destined for kids",
},
{
"id": 304,
"description":"Book destined for Teen",
},
{
"id": 305,
"description":"Only for teen under the age of 13",
},
]
},
{
"name": "Collection 1",
"details": [
{
"id": 400,
"description":"books for adults to read",
},
]
},
]
I need to add a new key/value which value should be a substring of description Something like [teen,kids,adults]
Expected output:
[
{
"name": "Collection 1",
"details": [
{
"id": 302,
"description":"Book destined for kids",
"age range":"kids"
},
{
"id": 304,
"description":"Book destined for Teen",
"age range":"teen"
},
{
"id": 305,
"description":"Only for teen under the age of 13",
"age range":"teen"
},
]
},
{
"name": "Collection 2",
"details": [
{
"id": 400,
"description":"books for adults to read",
"age range":"adults"
},
]
},
]
Anyone know a way How to do it in effective way using pandas please(I need to keep the same structure)