Find out dataframe index value under a certain condition
The simple code would be: df.index[condition] so something like this: df.index[df[‘column1’] == True].tolist() .tolist() is used when there are multiple values match the condition
The simple code would be: df.index[condition] so something like this: df.index[df[‘column1’] == True].tolist() .tolist() is used when there are multiple values match the condition
.item() will do the job: p1 = df[df[“column2”]==df.column2.max()].column1.item() print(p1) This way you can extract the actual value from pandas dataframe and store it in variable for later use.
Hello. I have been using np.arrange for a long time but only now I have noticed that this built-in function doesn’t include the last maximum value. Like for example: step = 2 print(np.arange(0, 26, step)) results in [0 2 4 6 8 10 12 14 16 18 20 22 24] So how do we make … Read more