My data frame has six columns of float data and around 80,000 rows. One of the column is "Current" and sometimes it is negative. I wanted to find index locations when the "Current" value is negative. My code is given below:
currnet_index = my_df[(my_df["Current"]<0)].index.tolist()
print(current_index[:5])
This gives output as I wanted:
[0, 124, 251, 381, 512]
This is fine. Is it possible to write this code using iloc
method? I tried with following code and but it is giving error. I am wondering to know which of them is best and fastest method?
current_index = my_df.iloc[(my_df["Current"]<0)]
The output is:
NotImplementedError: iLocation based boolean indexing on an integer type is not available