1

I'm trying to run through a for loop, but looking at the indices, rather than the values of the list. My list looks like this:

ubermin_values = [8350.1416, 13167.329, 29200.063, 19283.514, 23596.0309...]

and it has a total of 100 values (but this changes with each run of the program). I'm trying to keep track of which value in minimum_pixels each value in ubermin_values came from, for plotting. If I use this loop in my code,

ubermin_vals_x = []
for i in ubermin_values:
    value = ubermin_pixels[i]
    ubermin_vals_x.append(minimum_pixels[i])

it tries to iterate over the values (8350.1416, 13167.329...) but of course this can't be done. I think my scheme should work if I can iterate over the indices of ubermin_values, rather than the values, but I can't see how to do that.

If it helps, here's how the first values should be mapped: enter image description here

so that I can plot the points (4, 8350.1416), (10, 13167.329), (7, 29200.063), etc.

The numpy docs list nditer for iterating over arrays. Am I on the right track with this, or is there a better way to do it?

Jim421616
  • 1,434
  • 3
  • 22
  • 47
  • Why do you mention `numpy` when you are clearly using a `list`? – juanpa.arrivillaga Sep 08 '17 at 06:03
  • Ok @juanpa, thanks for those comments. I see that I can use `enumerate` to access the indices of the list, but I'm sorry that I can't see how to associate the values in the fourth list with the values in the first, as in my screenshot. How can I do that using a `for` loop? – Jim421616 Sep 08 '17 at 08:05

0 Answers0