I feel like I am asking a very silly question that has been asked a thousand times but I cannot seem to find it anywhere. I might be using the wrong terminology.
Anyway, I have a pandas frame df
. And I would like to use a part of this dataframe. More specifically I'd like to use it in a loop:
unique_values = df['my_column'].tolist()
unique_values = list(set(unique_values))
for value in unique_values:
tempDf = df[df['my_column] == value]
# Do stuff with tempDf
But this doesn't seem to work. Is there another way to 'filter' a dataframe by a column's value?