0

I am working on a journal entry database I want to check if row 1 and 2, then row 2 and 3,(and so on) have the same amounts based on same account no. (to check debit credit postings, please note, i have already sorted the data based on absolute function on amounts) I have used the following for loop:

Step 1:

Elimination=[]

Step2:

for i, j in range(sales_acc):
    if sales_acc ["Amount LC"][i]==sales_acc["Amount LC"][j] & sales_acc ["ACCOUNTNUMBER"][i]==sales_acc["ACCOUNTNUMBER"][j]:

    Elimination.append(i)
    Elimination.append(j)
else:
    pass

but this forloop gives me "expected an indented block"error

Can someone help me.

enter image description here

  • You need to indent the two lines after `if`, meaning you add four spaces before each `Elimination.append...` – mcsoini Jul 06 '21 at 08:35
  • Also, there is much better ways of doing this with pandas without for loops. Please provide some example data, ideally in a new question with a [minimal reproducible example](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). – mcsoini Jul 06 '21 at 08:37
  • @mcsoini Could you explain what are the other ways you are mentioning? I just added the example data as a picture. So need to compare amounts of row 1 to row 2 and so on append in case account numbers are also same – Celine Yesudass Jul 06 '21 at 08:45

0 Answers0