Calculating a unique count within a rolling time window
How about something like this:
test.rolling('7d').apply(lambda s:s.nunique()).groupby(level=0).max()

rolling('7d') is the rolling window. The window is determined for each row. So the first window starts from the row &quot;2020-01-01     4&quot; and extends 7 days in the past. The second window starts from the row &quot;2020-01-01    65&quot; and extends 7 days in the past.
.apply(lambda s:s.nunique()) determines the number of unique items in the window. But, because of the way rolling works, we get multiple results for the same day.
.groupby(level=0) groups the results by the date.
.max() takes the maximum nunique value for that date.
The above approach seemed rather slow, so here's a different approach. Basically use a Counter as a multiset and use a deque as a FIFO queue.  For each day update the Counter with the id's for that day and subtract the ones for the day at the beginning of the window.  The len of the Counter is then the number of unique ids.
from collections import Counter, deque

WINDOW = 7

fifo = deque(maxlen=WINDOW)
uniq = Counter()

def unique_in_window(x):
    if len(fifo) == WINDOW:
        uniq.subtract(fifo.popleft())
        
    uniq.update(x)
    fifo.append(x)
    
    return len(uniq)

test.groupby(level=0).apply(unique_in_window)