I have dataframe which has columns: free items, demand items quantity and type of item. I need to distribute free items on demand by types enter image description here
first items I calculated right, but it is not cover item type.
My code is:
df['ostatok'] = (df['Количество\nв БЕИ_y']-df['Количество\nвБЕИ_x'].cumsum()).shift(1).fillna(df['Количество\nв БЕИ_y'])
Please help me to solve this problem, thank you