I try to create a dataframe from nested dictionary in my pandas dataframe, but i can't make it work...
my dataframe :
created_at selected
2019-08-13T12:24:53+00:00 {"982813":false,"1786112":true,"3002218":false}
2019-08-31T13:47:51+00:00 {"309279":true,"1903384":false}
...
And i would like to create a new df with the selected column data formatted as follows :
created_at ID Value
2019-08-13T12:24:53+00:00 982813 false
2019-08-13T12:24:53+00:00 1786112 true
2019-08-13T12:24:53+00:00 3002218 false
2019-08-31T13:47:51+00:00 309279 true
2019-08-31T13:47:51+00:00 1903384 false
...
I've been trying to use explode() and json_normalize() without success so i decided to go for pd.DataFrame.from_dict() and a for loop like as follow but i'm getting an error.
x = {}
for row in df.selected:
pd.DataFrame.from_dict(row, orient='index')
But i'm getting the following error :
AttributeError: 'str' object has no attribute 'values'
i'm still a beginner in python so if someone as a idea/explanation i'm all ears.