I am trying to use multiple list of lists to add rows to a dataframe.
The error is as follows: IndexError: invalid index to scalar variable.
The code is below:
List_a = [[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15]]
List_b = [[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30]]
List_c = [[31,32,33],[34,35,36],[37,38,39],[40,41,42],[43,44,45]]
Some_List = ['0', '1', '2', '3', '4']
first_row = {'A': [0], 'B': [0], 'C': [0]}
All_Rows = pd.DataFrame(first_row)
#Optimized_Trades
for i in range(len(Some_List)):
for j in range(len(Some_List[i])):
df_temp = { 'A': List_a[i][j], 'B': List_b[i][j], 'C': List_c[i][j]}
All_Rows = All_Rows.append(df_temp, ignore_index = True)
All_Trades = All_Trades[1:]
display(All_Trades)
Ideally, the final output would be:
A B C
1 16 31
2 17 32
3 18 33
4 19 34
5 20 35
6 21 36
7 22 37
8 23 38
9 24 39
10 25 40
11 26 41
12 27 42
13 28 43
14 29 44
15 30 45