I'm trying to loop through a dictionary, but use the looped keys (or values if I so choose) in a calculation.
EDIT 11/24: Adding additional context
So the example would be:
STEP 1) I have a CSV file with the following columns... Column 1, Column 2, Column 3
file = pd.read_csv("/Path/test.csv")
time Change Column 1 Column 2 Column 3 Column 4
01/01 .5 3 5 7 1
01/01 .3 5 1 4 2
01/01 .5 1 3 8 2
01/02 .3 5 1 4 1
01/02 .5 1 3 8 3
STEP 2) I have a dictionary that groups these columns and provides information regarding the calculations required for the columns in Key Value pairs. I am additionally assigning a code to each column for use later (NOTE: There are 10 groups of columns, containing anywhere from 4-20 columns per group, below is simply an example):
dict = {
'group': {
'a':{
'ranges':{
'a':{'<':0,'>':-1},
'b':{'<':0,'>':-2}}
'indicators':{
'a':'Column 1',
'b':'Column 2'}
'b':{
'ranges':{
'a':{'<':0,'>':-1},
'b':{'<':0,'>':-2}}
'indicators':{
'a':'Column 3',
'b':'Column 4'}
STEP 3 [This is where I'm having trouble]) The 'Groups' are a collection of columns with 'similar' data as well as corresponding ranges I want to test against. I am trying to compare different combinations of groups with other groups. So compare ALL the different RANGES of Column 1 to all the different RANGES of Column 3, then 4... then compare ALL the different RANGES of Column 2 to all the different RANGES of Column 3, then 4. My thought was to assign a CODE based on the corresponding letters for GROUP, RANGES, and INDICATORS... so for example "aaa" would be GROUP a, RANGES {'<':0,'>':-1}, in INDICATOR Column 1
NOTE: I only need to compare 3 columns at a time, e.g. the loop can stop at 3 combinations, however I'd like to also know if 2 combinations are better than 3.
STEP 4) I want to group the different combinations to see which combinations of COLUMNS and RANGES work the best, by calculating the MEAN, MAX, MIN, and then COUNT of each combination.
I am attempting to create a huge loop for this, but in an effort to learn on my own I'm only asking the community pieces of it. But I'm seeing that this piecemeal approach isn't helpful to understand the context of my issue. So hopefully this additional explanation provides a bit more clarity
My eventual desired output:
Code Average Max Min Count
aaa 0.25 0.5 0.3 3
aab 0.25 0.5 0.3 3
aac 0.25 0.5 0.3 3
aba 0.25 0.5 0.3 3
abb 0.25 0.5 0.3 3
abc 0.25 0.5 0.3 3