Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def formula(df):
- formula = np.zeros([len(df.period.unique()),1])
- for i in range(len(period.unique())):
- count = 0
- amount = 0
- dt = df[df.datetime==fd.period.unique()[i]]
- for j in range(len(dt)):
- if count + dt.amount[j] <= 500:
- count = count + dt.amount[j]
- priceamount = amount + dt.amount[j]*dt.price[j]
- else:
- diff = 500-count
- priceamount = priceamount + diff*dt.price[j]
- formula[i] = priceamount/500
- break
- return formula
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement