I am trying to filter a dataframe by the values inside one of the columns. The dataframe has a Gender
column. And I am trying to filter the values by fetching only the columns that have 'Female' in the Gender
column.
When I filter using lambda:
df = df.loc[lambda x: x['Gender'] == 'Female']
I get the correct results, but I am required to use the .where()
method. When I use the following line instead, I get zero results:
filter = df['Gender'] == 'Female'
df = df.where(filter, inplace = True)
Why is this?