pandas df.index.values

df = pd. read_csv("fruits.csv")
print(df)
index = df. index.
condition = df["fruit"] == "apple"
apples_indices = index[condition] get only rows with "apple"
apples_indices_list = apples_indices. tolist()
print(apples_indices_list)
Gentle Gaur