Answers for "python sliding window"

1

python sliding window

def window(iterable, size=2):
    i = iter(iterable)
    win = []
    for e in range(0, size):
        win.append(next(i))
    yield win
    for e in i:
        win = win[1:] + [e]
        yield win
Posted by: Guest on March-03-2020

Python Answers by Framework

Browse Popular Code Answers by Language