This is my data
import numpy as np
class_data=[np.array(['class3','class5']),np.array(['claas1','class9'])]
data=[['dog.txt','cat.txt'],['mouse.txt','horse.txt']]
needed result is to create the dictionary that looks like that:
[[{'text': 'dog.txt', 'class': 'class3'},
{'text': 'cat.txt', 'class': 'class5'}],
[{'text': 'mouse.txt', 'class': 'class1'},
{'text': 'horse.txt', 'class': 'class9'}]]
I attempt to:
out_data=[]
for kk,kb in zip(class_data,data):
for ii,kb2 in enumerate(kb):
for i,v in enumerate(kk):
out_data.append({'text': kb2, 'class': v})
out_data
which makes every possible combination from each identical array which is wrong.
[{'text': 'dog.txt', 'class': 'class3'},
{'text': 'dog.txt', 'class': 'class5'},
{'text': 'cat.txt', 'class': 'class3'},
{'text': 'cat.txt', 'class': 'class5'},
{'text': 'mouse.txt', 'class': 'claas1'},
{'text': 'mouse.txt', 'class': 'class9'},
{'text': 'horse.txt', 'class': 'claas1'},
{'text': 'horse.txt', 'class': 'class9'}]
this solution should work iteratively and also can work with the larger datasets