I have a dictionary with structure:
Level 1:
- id (int)
- username (str)
- meta (contain a string of Kpi_info)
This is a dictionary:
dict = {'id': 206, 'username': 'hantran','meta': '{"kpi_info":\
{"2021" :{"1":{"revenue":"2000", "kpi":"2100","result":"0"}, "2":{"revenue":"2500", "kpi":"2000", "result":"1"}},\
"2022": {"1":{"revenue":"3000", "kpi":"2500","result":"1"}, "2":{"revenue":"2500", "kpi":"3000", "result":"0"}}}'
}
My desire result is a DataFame like this:
id | username | Year | Month | revenue | kpi | result |
---|---|---|---|---|---|---|
206 | hantran | 2021 | 1 | 2000 | 2100 | 0 |
206 | hantran | 2021 | 2 | 2500 | 2000 | 1 |
206 | hantran | 2022 | 1 | 3000 | 2500 | 1 |
206 | hantran | 2022 | 2 | 2500 | 3000 | 0 |
Apparently, similar question has been discussed here. However, the solution only work for 3-level dictionary. I don't know how to make it work for my 1-level dictionary with most of the needed information is in a string.