I've a data structure which is dynamically populated, so number of keys and sub-keys are unknown. I want to convert it into a Pandas df. The structure looks like this
datastore = {
"user1":{
"time1":[1,2,3,4],
"time2":[5,6,7,8],
"time3":[1,2,3,4] },
"user2":{
"time1":[1,2,3,4],
"time2":[5,6,7,8] }
}
A dict of dicts with lists for value
I want to convert it into pandas df like this
index users times x y z k
0 user1 time1 1 2 3 4
1 user1 time2 5 6 7 8
2 user1 time3 1 2 3 4
3 user2 time1 1 2 3 4
4 user2 time2 5 6 7 8
....
I've tried pd.DataFrame(dict), from_dict method but couldn't get it to work. Any help would be appreciated.
EDIT: Sorry about the syntax error, fixed