我正在尝试根据日期范围创建新列,以了解每个条目每月花费多少EMI。在python中,请告知如何做到这一点
输入文件
Start Date End Date EMI
01/12/16 01/12/17 4800
09/01/16 09/01/17 3000
01/07/15 01/05/16 2300
我希望输出文件看起来像这样
Start Date End Date EMI 06/16 07/16 08/16 09/16 10/16 11/16 12/16 01/17 02/17
01/12/16 01/12/17 4800 4800 4800 4800 4800 4800 4800 4800 4800 0
09/01/16 09/01/17 3000 0 0 0 3000 3000 3000 3000 3000 3000
01/07/15 01/05/16 2300 0 0 0 0 0 0 0 0 0
请告诉我你使用python实现这个的建议。
答案 0 :(得分:0)
你需要的IIUC:
def bidirectional_bubble_sort(a):
left = -1
right = len(a)
while left < right:
swap = False
left += 1
right -= 1
for i in xrange(left, right):
if a[i] > a[i + 1]:
t = a[i]
a[i] = a[i + 1]
a[i + 1] = t
swap = True
if not swap:
return
else:
swap = False
for i in xrange(right - 1, left - 1, -1):
if a[i] > a[i + 1]:
t = a[i]
a[i] = a[i + 1]
a[i + 1] = t
swap = True
if not swap:
return