挣扎的事情应该很容易:
today = '26/8/2018'
start = '1/8/2018'
diff = today - start
diff给了我们26天
如何获取此日期时间的整数值?即26?
基本上,我试图计算日计数分数((diff / 365)* 10,000),但它无法正常工作。
我的实际值是:
0 304.548
1 371.397
2 350.466
3 -3574.36
4 255.452
,即时通讯试图将它们乘以: 持续时间
0 13 days
1 2 days
2 1 days
3 20 days
4 7 days
但是我得到了
0 TimedeltaIndex(['3959 days 02:57:32.054794', ...
1 TimedeltaIndex([ '4828 days 03:56:42.739725', ...
2 TimedeltaIndex([ '4556 days 01:18:54.246575', ...
3 TimedeltaIndex(['-46467 days +08:52:36.164383'...
4 TimedeltaIndex(['3320 days 21:02:27.945204', ...
所需的输出是
0 3959.124
为整数(304.548 * 13),而不是为daycount
答案 0 :(得分:2)
也许这样的事情可能有用:
In [1]: import datetime
In [4]: diff = datetime.datetime.today() - datetime.datetime(year=2018, month=8, day=1)
In [5]: diff.days
Out[5]: 25
然后您可以执行以下操作:
In [10]: diff.days / 365 * 10000
Out[10]: 684.931506849315