Python Forum
Pandas (Python) in powerBI loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas (Python) in powerBI loop
#1
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
   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PowerBI: Using Python Regex to look for values in column MarcusR44 1 967 Oct-14-2022, 01:03 PM
Last Post: ibreeden
  export into excel, how to implement pandas into for-loop deneme2 6 2,439 Sep-01-2022, 05:44 AM
Last Post: deneme2
  Increase the speed of a python loop over a pandas dataframe mcva 0 1,313 Jan-21-2022, 06:24 PM
Last Post: mcva
  For Loop Works Fine But Append For Pandas Doesn't Work knight2000 2 2,007 Dec-18-2021, 02:38 AM
Last Post: knight2000
  for loop in dataframe in pandas Paulman 7 2,747 Dec-02-2021, 12:15 AM
Last Post: bowlofred
  Pandas, How to trigger parallel loop Mekala 4 2,714 Oct-29-2020, 12:58 PM
Last Post: Mekala
  loop through python pandas data frame Johnse 4 2,845 Sep-02-2019, 01:45 AM
Last Post: Johnse

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020