我正在用Python尝试这段代码。
count1=0
count2=0
count3=0
count4=0
for i in range(len(col_1)):
a=col_1[i]
for j in range(len(a)-1):
delta=pd.to_datetime(a[j])-pd.to_datetime(a[j+1])
x=delta.days
if(x>=0)and(x<30):
count1=count1+1
elif(x>30)and (x<=60):
count2=count2+1
elif(x>=60) and (x<=90):
count3=count3+1
else:
count4=count4+1
This is the error I am getting
我希望通过减去各个日期来获得天数。
['2019-05-01', '2019-06-01', '2019-07-01', '2019-08-01', '2019-09-01', '2019-10-03', '2019-11-01']
我们可以看到,第一次减法将显示30天,从第三次日期到第二个日期的减法将显示30天,依此类推。