I have several lists that are generated from a get_topic() function. That is,
list1 = get_topic(1)
list2 = get_topic(2)
and another dozens of lists.
# The list contains something like
[('A', 0.1),('B', 0.2),('C',0.3)]
I am trying to write a loop so that all different lists can be saved to different columns in a dataframe. The code I tried was:
for i in range(1,number) # number is the total number of lists + 1
df_02 = pd.DataFrame(get_topic(i)
This only returns with list1, but no other lists. The result that I would like to get is something like:
| List 1 | Number 1 | List 2 | Number 2 |
|---|---|---|---|
| A | 0.1 | D | 0.03 |
| B | 0.2 | E | 0.04 |
| C | 0.3 | F | 0.05 |
Could anyone help me to correct the loop? Thank you.