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

Asked 2 weeks ago, Updated 2 weeks ago, 1 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


© 2022 pinfo. All rights reserved.