我想找出日期列表之间的天数差异。
我有一个时间戳对象列表。
[Timestamp('2016-10-18 00:00:00'), Timestamp('2016-10-18 00:00:00'), Timestamp('2016-10-19 00:00:00'), Timestamp('2016-10-29 00:00:00'), Timestamp('2016-10-31 00:00:00'), Timestamp('2016-11-01 00:00:00'), Timestamp('2016-11-09 00:00:00'), Timestamp('2016-11-09 00:00:00'), Timestamp('2016-11-11 00:00:00'), Timestamp('2016-11-13 00:00:00'), Timestamp('2016-11-13 00:00:00')]
And I want the following result
[0,1,10,2,1,8,0,2,2,0]
我尝试了下面的代码,但是遇到编译错误:“TypeError: 'Timestamp' object is not iterable”。
def calculateInterOrderTime(dateList):
result = map(lambda x: [i / np.timedelta64(1, 'D') for i in np.diff([c for c in x])[0]],dateList)
print(list(result))
如果有人能够帮助我编写Lambda表达式,让它实现我的期望,那就太好了。