I am trying to create dataframe . from a combination of dataframe with a cross dictionary as below
dataframe contains multiple columns "N numbers of columns x,y,z,a,b,c ......etc more than 100 columns "
df = pd.DataFrame({'ID':['EF407412','KM043272']
, 'x': ['[2788, 3140, 4836]','[539, 906, 1494, 1932, 2029,7001]']
, 'y': ['[1408, 1572, 2277]','[]']
# dataframe contains multiple columns "N numbers of columns x,y,z,a,b,c ......etc more than 100 columns "
})
dictionary name is scale, and its items (keys to values) are Customizable and transformation rules from input dataframe to output dataframe were mentioned in the below comments
scale = ("500-10000", {
# Key= Scales and value = Weights, both Customizable
500: 7000, # key is 500 and value is compared with List as List items >= 7000
2500: 3000, # key is 2500 and value is compared with List as List 7000 > items >= 3000
5000: 1000, # key is 5000 and value is compared with List as List 3000 > items >= 1000
7500: 400, # key is 7500 and value is compared with List as List 1000 > items >= 400
10000:250 # key is 10000 and value is compared with List as List 400 > items >= 250
# any others List items < 250 will be neglected
# any others List items < 250 will be neglected })
important p.s >>> If the input list items contain redundant data, it will be treated in the output as separate values. for example x column contain List [4836, 4836, 4836] output inside column of x_2500 will be [4836, 4836, 4836]
