List1= ["0","6","6","11","11","20","20","30","30","40","40","99"]
list2=["minvalue","maxvalue"]
List3=["A","B","C","D","E","F"]
List of dictionary i want is
Result=[{"minvalue":"0","maxvalue":"6","category":"A"}, {"minvalue":"6","maxvalue":"11","category":"B"}, {"minvalue":"11","maxvalue":"20","category":"C"}, {"minvalue":"20","maxvalue":"30","category":"D"}, {"minvalue":"30","maxvalue":"40","category":"E"}, {"minvalue":"40","maxvalue":"99","category":"F" }]
Everything should be string in list of dictionary
I tried below snippet
List4=[{'"category':coun, 'minvalue': cap, 'maxvalue': curr} for coun,cap,curr in zip(list1,list2,list3)]
this is not working as lists are of variable length, list1 has 6 elements,list2 has 2 elements and list3 will have 4-12 elements
I even tried this
x=[list(i) for i in list(np.array_split(list1, 6))]
alpha_idx = {0:'A', 1:'B', 2:'C', 3:'D', 4:'E', 5:'F'}
result = []
for i in x:
maximum, minimum = max(i), min(i)
d = {}
d['category'] = alpha_idx[x.index(i)]
d['maxvalue'] = str(maximum)
d['minvalue'] = str(minimum)
result.append(d)
This is working but problem comes when list1 has NA as it's value example
List1=['1','5','NA','5','20','NA','20','50','50','99']
This above list essentially means for some category there might not be any min or max value present