Try via filter(),gt() and mean():
out=df.filter(like='Revenue')
df['Average']=out[out.gt(1000)].mean(axis=1)
output of df:
Name Revenue1 Revenue2 Revenue3 Average
0 Peter 1000 2000 3000 2500.0
1 Jane 9000 10000 5000 8000.0
Breakdown of code:
Firstly we select all the columns that Named like 'Revenue' via filter() method and it will give a DataFrame of columns named like that so we are storing it in out variable
out=df.filter(like='Revenue')
#output of above code:
Revenue1 Revenue2 Revenue3
0 1000 2000 3000
1 9000 10000 5000
Then we will filter out rows where values is greater than 1000:
out.gt(1000)
#your condition
#output of above code:
Revenue1 Revenue2 Revenue3
0 False True True
1 True True True
As you saw the condition gives you boolean values so now we will pass that boolean mask to out so where there is True in the above boolean values you will get the values and where there is False you will get NaN this is know as boolean masking:
out[out.gt(1000)]
#output of above code:
Revenue1 Revenue2 Revenue3
0 NaN 2000 3000
1 9000.0 10000 5000
Finally we will calculate mean via mean() method on axis=1 so the NaN's are ignored..In other words mean() method doesn't considered NaN's while calculating mean(because by default skipna=None in mean() method)
out[out.gt(1000)].mean(axis=1)
#output of above code:
0 2500.0
1 8000.0
dtype: float64
Finally we will assign this result back to df:
df['Average']=out[out.gt(1000)].mean(axis=1)
Update:
If df also has other numerical columns like 'Income' and you also want to include it in your calculation along with columns like 'Revenue' then use:
out=df.filter(regex='Revenue|Income')
df['Average']=out[out.gt(1000)].mean(axis=1)