I have a dataframe similar to this:
>>> d = {'ID': ['ID1', 'ID2', 'ID3', 'ID4', 'ID5', 'ID6', 'ID7', 'ID8', 'ID9', 'ID10'],
'A': [1, 1, 1, 1, 2, 2, 2, 2, 2, 2],
'B': [145,158,240,250,199,204,300,350,467,578]}
>>> df = pd.DataFrame(data=d)
I want to create a new series, F, to flag every 100 units of column B (starting to count from the first value in column B, not from 0). The numbers from column B "restart" for every number in the column A. For a new number in column A, it should start a new flag and take the respective value from column B as first number of the new range of 100. To clarify, the expected outcome for this situation would be:
>>> outcome = {'ID': ['ID1', 'ID2', 'ID3', 'ID4', 'ID5', 'ID6', 'ID7', 'ID8', 'ID9', 'ID10'],
'A': [1, 1, 1, 1, 2, 2, 2, 2, 2, 2],
'B': [145,158,240,250,199,204,300,350,467,578],
'F': ['F1','F1','F1','F2','F3','F4','F4','F5','F6','F7']}
>>> outcome
A B F
ID1 1 145 F1
ID2 1 158 F1
ID3 1 240 F1
ID4 1 250 F2
ID5 2 199 F3
ID6 2 204 F3
ID7 2 300 F4
ID8 2 350 F4
ID9 2 467 F5
ID10 2 578 F6
I hope it all made sense, thanks in advance!