To json_nnormalize when the value in the python pandas dataframe is a string of json structure

Asked 1 years ago, Updated 1 years ago, 108 views

index      str_json
0            {"KEY1":1,"ai_count":0,"KEY2":0,"KEY3...
1            {"KEY1":1,"ai_count":0,"KEY2":0,"KEY3...
2            {"KEY1":1,"ai_count":0,"KEY2":0,"KEY3...
3            {"KEY1":1,"ai_count":0,"KEY2":0,"KEY3...
...

Data frame as above, str_json is a string of json structure. If it's just a json value, the json_nnormalize function allows you to make a data frame flat as the key value becomes a column, but how do you handle the string structure?

python python3.6 pandas

2022-09-20 15:54

1 Answers

If you write json.loads, replace the json string of the string type with dict.


2022-09-20 15:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.