Nov-08-2021, 12:54 AM
Good evening please i need your help I wrote this code to calculate the final stock; the problem is that I want to apply a loop on 'code article' and 'division'. each article in one of its two divisions has its own stock
the stock of the article in the 2 divisions is independent
code
'dataset' holds the input data for this script
import pandas as pd
DX= pd.DataFrame(dataset.loc[:,])
AAA = []
for i in range(len(DX)):
if(i==0):
var = DX['Stock 10 fixe'][0] + DX['Livraison'][i]-DX['consomation'][i]
AAA.append(var)
else:
var = var + DX['Livraison'][i]-DX['consomation'][i]
AAA.append(var)
DX['stock Final']=AAA
this is the result :
https://i.stack.imgur.com/CorJy.png
the stock of the article in the 2 divisions is independent
code
'dataset' holds the input data for this script
import pandas as pd
DX= pd.DataFrame(dataset.loc[:,])
AAA = []
for i in range(len(DX)):
if(i==0):
var = DX['Stock 10 fixe'][0] + DX['Livraison'][i]-DX['consomation'][i]
AAA.append(var)
else:
var = var + DX['Livraison'][i]-DX['consomation'][i]
AAA.append(var)
DX['stock Final']=AAA
this is the result :
https://i.stack.imgur.com/CorJy.png