I have the above data, would like to loop through each fund_id, keep all bank name with comb, throw out corresponding matches to comb and retain max 4 months, if no comb, keep 4 most recent months to get avg. Whats's the best way to do this and results should look something like this