all_values = [0, 0.5, nan, 0.2, 0.3, 0.4]
sorted_values = sorted(all_values)
top = [item for item in sorted_values if item < sorted_values[1]]
print(all_values, sorted_values)
print(top, len(top))
# output
[0, 0.5, nan, 0.2, 0.3, 0.4] [0, 0.5, nan, 0.2, 0.3, 0.4]
[0, 0.2, 0.3, 0.4] 4