Is there a way to make my loop work with no errors because there is no next value? Or not to use a foor loop for this at all?
Inside this function below I have another function with a for loop:
def funcA(self,perc,bloc):
def funcA1(self):
maxIndex = len(self)
localiz = self.loc
for x in range(0,maxIndex-1):
if localiz[x,bloc] == localiz[x+1,bloc]:
localiz[x,"CALC"] = True
else:
localiz[x,"CALC"]= False
return self
I got it working by creating first the column "CALC" with False because the last line of my df will always be False. But surely there is a better way.
EDIT I'm basically using pandas and numpy for this code.
The bloc that i'm using in the function is the ID column The data structure I'm working with is like this:
ID NUMBER
2 100
2 150
3 500
4 100
4 200
4 250
And the expected results are:
ID NUMBER CALC
2 100 True
2 150 False
3 500 False
4 100 True
4 200 True
4 250 False
def funcA1(self):.localiz? (how can you access elements withlocaliz[x,"CALC"]?)