当日期在前10天窗口中出现时,我想从datetimeindex中删除所有条目。我已经以一种安静的丑陋的方式实现了它:
date_list.head()
Date
1990-06-13 17.379999
1990-06-14 17.400000
1991-05-15 18.379999
1991-05-16 17.240000
1991-05-17 16.639999
i = 0
p = 0
margin = 10
lst = [pd.Timestamp(year = 1900, month = 1, day = 1)]
while i < len(date_list.index):
date = date_list.index[i]
if date > (lst[p] + timedelta(margin)):
lst.append(date)
p += 1
i += 1
lst = lst[1:]
有人知道如何通过简单的单行过滤器功能实现相同的结果吗?