News

New paper! in the American Naturalist

Friday, December 7, 2018

Select rows of pandas.DataFrame with complex criteria

Just to view the rows whose column A > x and B = y:
df[(df.A > x) & (df.B == y)]

However, in order to change the values in column A in rows that satisfy the condition,
df.loc[(df.A > 50) & (df.B == y), "A"] = x