Python Forum
finding index to given value from dataset
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
finding index to given value from dataset
#1
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?
Reply
#2
"q += q" should be: "q += 1"
Reply
#3
Thanks a lot
Reply
#4
You are welcome.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Getting Index Error - list index out of range krishna 2 2,568 Jan-09-2021, 08:29 AM
Last Post: buran
  Getting Index Error - list index out of range RahulSingh 2 6,102 Feb-03-2020, 07:17 AM
Last Post: RahulSingh

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020