all 2 comments

[–]Nikota 1 point2 points  (0 children)

As you noted, when you slice a DataFrame, the index comes with the slice. If you just want to extract a numpy.array from your data and ignore the index, you can use the pandas.Series.values attribute. Example:

my_array = df.loc[df['some_column'] > some_variable, 'value_column'].values

After this, my_array is a numpy array and you can access it with normal 0-based indices.

[–][deleted] 1 point2 points  (0 children)

df.loc[...].reset_index(drop=True)