Python Forum

Full Version: finding index to given value from dataset
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I have some data and I want to find out the index of the minimum. Since the data structure is not a list, I can't just use the
list.index()
command. I came up with the idea to loop through the data and if I find the minimum, I save the position.
i = 0
q = 0
mini = data['open'].min()
for x in data['open']:
        
    if x == mini:
        i = q
    q +=q
print("index = ")    
print(i)
When I run the program, I don't get any error but i = 0 what I don't understand since I found a minimum in the dataset with
 mini = data['open'].min()
.
Any idea whats going wrong here?
"q += q" should be: "q += 1"
Thanks a lot
You are welcome.