I'm very new to programming (<2 weeks), and am having to learn Python3 as part of a course, so please bear that in mind in any answers! I'm working on a new Mac, in case that makes a difference.
I've got a table of data, which was taken from a csv file and compiled into 3 columns, with several thousand rows. I've filtered out quite a lot of the rows based on certain conditions, leaving me with about 200 rows (but whose index is from about 8000-8300, because of the initial ordering). Now I'm trying to find the time (one of the columns) at which the highest value in another of the columns occurred. When I run the code below, it gives me an error "index out of bounds". I've read another question here on the same error message, but I didn't really understand how the answer could be applied here.
maxrow=df['A'].idxmax()
maxA=df['A'].irow(maxrow)
maxtime = df['time'].irow(maxrow)
maxB = df['B'].irow(maxrow)
I understand that the first line is finding the row in which A is at a maximum and assigning a variable "maxrow" to have that row number. The second line is creating a variable maxA and assigning to it the value found in column A at its maximum row. At this stage, though, it seems to create a problem. I should mention that if I insert a row number of less than 200 instead of "maxrow" in the 3rd, 4th and 5th lines, there is no problem at all (except that it's not the right row chosen).
So I think somehow the program is identifying the max row based on its index number, but then when it comes to use it, it is using the actual new ordering of the rows, of which there aren't enough.
Can anyone help? Thanks