I have two lists containing float values:
mean_fall_1 = [statistics.mean(d) for d in fall_1_gpa]
stdev_fall_1 = [statistics.stdev(d) for d in fall_1_gpa]
where:
fall_1_gpa = [[mean(sub_list) for sub_list in list] for list in fall1_grades]
Furthermore, I have a list of strings:
combination_fall_1 = [['CS105','MATH101','ENG101','GER'],['CS105','MATH101','GER','GER']]
fall1_grades = [[[4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0]],[[4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0], [4.0, 3.33, 3.33, 4.0]]]
mean_fall_1 = [2.9687393162393163,3.419960107803423]
stdev_fall_1 = [0.33945301919611576,0.2821718924791329]
What I am trying to do is to find the best combination of mean_fall_1 and stdev_fall_1 and list them(show first the highest mean possible with the lowest stdev possible and rank them like this). What I do is:
mean_fall_1, stdev_fall_1 = sorted(
list(zip(*(zip(mean_fall_1, stdev_fall_1)))))
mean_fall_1, stdev_fall_1 = (list(t) for t in sorted(list(zip(*(zip(mean_fall_1, stdev_fall_1))))))
and when I print(stdev and then mean) I get this result:
[0.2821718924791329, 0.33945301919611576]
[3.419960107803423, 2.9687393162393163]
but I want the combination_fall_1 list to be sorted accordingly with this in order for me to be able to show the user the combination of courses and not the mean and stdev only. I tried doing this:
mean_fall_1, stdev_fall_1,combination_fall_1 = sorted(
list(zip(*(zip(mean_fall_1, stdev_fall_1,combination_fall_1 )))))
mean_fall_1, stdev_fall_1 = (list(t) for t in sorted(list(zip(*(zip(mean_fall_1, stdev_fall_1,combination_fall_1 ))))))
But I keep getting this error:
TypeError: '<' not supported between instances of 'list' and 'float'
Is there another way to sort the combination_fall_1 list according to the other 2? or am I missing something?
The desired output:
[['CS105','MATH101','GER','GER'],['CS105','MATH101','ENG101','GER']]
Since the mean of ['CS105','MATH101','GER','GER']
is 3.419960107803423 and its st.dev 0.2821718924791329 which is better combination of ['CS105','MATH101','ENG101','GER']
with mean 2.9687393162393163 and st.dev 0.33945301919611576