If you want an all-or-nothing type comparison I think a fairly easy way is to use set comparisons:
if(set(list_of_cols_to_check).issubset(df.columns)):
filtered_df = df[(df.numA < x) & ... & (df.numB < y)]
If you want to perform comparisons for all that do exist it gets a bit more complicated. It is not very different than what you have, but I'd probably do it as follows:
filter = (df.index >= 0) #always true
filter = filter & (df.numA < 4) if 'numA' in df else filter
filter = filter & (df.numB < 2) if 'numB' in df else filter
filter = filter & (df.numC < 1) if 'numC' in df else filter
df[filter]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…