I currently have a list of dictionaries shown below:
temp_indices_=[{0: {12:11,11:12}}, {0: {14:13,13:14}}, {0: {16:15,15:16}}, {0: {20:19,19:20}},{0: {24: 23, 23: 24, 22: 24}, 1: {24: 22, 23: 22, 22: 23}},{0: {28: 27, 27: 28, 26: 28}, 1: {28: 26, 27: 26, 26: 27}}]
To convert the list into a dataframe, the following code is called:
temp_indices= pd.DataFrame()
for ind in range(len(temp_indices_)):
# print(ind)
temp_indices = pd.concat([temp_indices,pd.DataFrame(temp_indices_[ind][0].items())],axis=0)
temp_indices = temp_indices.rename(columns={0:'ind',1:'label_ind'})
An example output from temp_indices is shown below which should concat all dictionaries into one dataframe:
ind label_ind
0 12 11
1 11 12
0 14 13
1 13 14
0 16 15
1 15 16
0 20 19
1 19 20
0 24 23
1 23 24
2 22 24
0 28 27
1 27 28
2 26 28
0 28 26
1 27 26
2 26 27
To improve speed I have tried out pd.Series(temp_indices_).explode().reset_index()
as well as pd.DataFrame(map(lambda i: pd.DataFrame(i[0].items()), temp_indices_))
but can not drill down to the core dictionary to convert it to a dataframe.