My dataset has 3 columns - a,b,c. Using b (and its history), I wish to predict c. Using list function and converting to array, I can tell python to look at last 20 b's for any b, as input to predict c. Now, I wish to tell the code, to look at those last 20 b's where the 'a' value is same, and in case it doesn't find 20 such entries with same 'a' value, then it should look at as many entries as there are available with same value of 'a'