After concatenating of 2 lists the commas are gone. But for columnar I need the commas. How to get them back ?
data list: [['bc1qxerefpfv3eaje77pmz44uuhkrtuss96pr8l86h', '0.01001904'], ['bc1qqd3v30aq6fsjnyl236rft7607rcdj4sjj3f4ty', '0.00476636']]
receiver list: [['36P29dTs6XnAiVxiMxZqmKBm1bFpsHfueR', '0.00167392'],['3D38TeCNgMdJBScz5CXnKkuKSUZpU7Y4mH', '0.01011148']]
import numpy as np
result=np.concatenate((data,receiver),axis=1)
result:[['bc1qxerefpfv3eaje77pmz44uuhkrtuss96pr8l86h' '0.01001904'
'36P29dTs6XnAiVxiMxZqmKBm1bFpsHfueR' '0.00167392']
['bc1qqd3v30aq6fsjnyl236rft7607rcdj4sjj3f4ty' '0.00476636'
'3D38TeCNgMdJBScz5CXnKkuKSUZpU7Y4mH' '0.01011148']]
2 Lists:
[[1,2],[3,4],[5,6],[7,8],[9,5]]
[[23,56][78,89]]
output should be:
1 2 23 56
3 4 78 89
5 6
7 8
9 5
result = list(map(list.__add__, list1, list2))
doesn't work
CodePudding user response:
Based on your last edit, it seems that you could use itertools.zip_longest
. Use a triple loop and set your brackets right to get the desired structure:
from itertools import zip_longest
data = [[1,2],[3,4],[5,6],[7,8],[9,5]]
receiver = [[23,56],[78,89]]
result = [[x for l in tup for x in l] for tup in zip_longest(data, receiver, fillvalue=[])]
Output:
[[1, 2, 23, 56], [3, 4, 78, 89], [5, 6], [7, 8], [9, 5]]