减少熊猫交易循环

时间:2020-05-14 11:18:34

标签: python pandas

我需要记录交易清单并减少它们以创建新交易清单。我了解我需要做的事情背后的数学原理,但是无法理解代码。我认为我需要一些复杂的循环,并且希望使用熊猫来实现。本质上,我需要:

copy the balance sheet so account numbers can be deleted as they are used in the code  
create an empty dataframe to store the new transactions  
Ac = ascii_out (account number) with highest balance   
Ad = ascii_out (account number) with lowest balance  
MaxCredit = amount to be credited to Pc (value from balancesheet)   
MaxDebit = amount to be debited from Pd (value from balancesheet)  
x = lowest value between MaxCredit and MaxDebit (most likely to be MaxDebit most of the time)  

需要创建一个变量,该变量:
如果x为负数,并且来自广告,则将x从广告转移到Ac
如果x为正且来自Ad,则将x从Ac转移到Ad
但是,必须将x作为正值插入到新数据框中。
然后,无论哪个ascii_out帐户x来自(Ac / Ad),都从资产负债表中删除,然后为下一个Ac和Ad重复该过程。

结果应为[ascii_out],[ascii_in],[amount]的数据框

编辑:

ascii_out余额
67 -18389
77 9583
65 -4601
69 7732
70 9632
74 -15567
66 5415
72 -3167
76 18115
71 -8876
73 3257
75 13804
68 -16938

0 个答案:

没有答案
相关问题