I have a pandas DataFrame (df) with many columns, two of which are "Year" and "col_1"
I also have a extraction criteria summarised in a list(Criteria):
[1234,5432,...,54353,654,1234].
I would like to extract the subset of this DataFrame if the following criteria are met:
((df.Year==1990) & (df.col_1>=Criteria[0])) or
((df.Year==1991) & (df.col_1>=Criteria[1])) or
((df.Year==1992) & (df.col_1>=Criteria[2])) or
...
((df.Year==2010) & (df.col_1>=Criteria[20])) or
((df.Year==2011) & (df.col_1>=Criteria[21]))
Although I can list out all the combination of these criteria, I would like to do this in one short line, something like:
df = df[df[['col_1','col_2']].apply(lambda x: f(*x), axis=1)]
(from how do you filter pandas dataframes by multiple columns)
Please advise how I can do it. Thank you.