I'm trying to get a jagged 2D list that looks like this
l = [
[(1, 0.8656769), (2, 0.08902887), (5, 0.040293545)],
[(1, 0.5918752), (2, 0.04440181), (4, 0.05204634), (5, 0.3066661)],
[(1, 0.26327166), (2, 0.26078925), (4, 0.24160784), (5, 0.22958432)],
[(2, 0.92498404), (5, 0.065140516)],
[(1, 0.9882947)],
[(0, 0.23412614), (1, 0.031903207), (2, 0.03044448), (3, 0.6480669), (4, 0.053342175)],
[(0, 0.056099385), (3, 0.9084766), (5, 0.031809118)],
[(2, 0.39833495), (4, 0.52058107), (5, 0.077259734)],
[(0, 0.46812743), (1, 0.10643007), (3, 0.15962379), (4, 0.017917762), (5, 0.24552101)],
[(0, 0.2556301), (1, 0.7391994)]
]
to become a data frame that looks like this:
In l, each row may or may not contain all columns. Each tuple is structured as follows (column_label, cell_value). If a column is missing for the row, its value should be set to 0 in the data frame.
I've tried
topics_df = pd.DataFrame(l).fillna(0)
but this results in a data frame that looks like this:

