Make the replacement block like this. Also note this assumes your arr will be strictly in multiples of 5 and there will be as many blocks like b1,b2 etc as there are blocks in arr as given in the example.
for i,b_arr in enumerate(d):
temp_arr = []
for j in range(5):
if j