I have the following Dataframe:
data = {'level1':[20,19,20,21,25,29,30,31,30,29,31],
'level2': [10,10,20,20,20,10,10,20,20,10,10]}
index = pd.date_range('12/1/2014', periods=11)
frame = pd.DataFrame(data, index=index)
In [75]: frame
Out[75]:
level1 level2
2014-12-01 20 10
2014-12-02 19 10
2014-12-03 20 20
2014-12-04 21 20
2014-12-05 25 20
2014-12-06 29 10
2014-12-07 30 10
2014-12-08 31 20
2014-12-09 30 20
2014-12-10 29 10
2014-12-11 31 10
I would like to take a "cell" of this frame, and find out which row it is in.
In other words, frame.level1[4]."rownumber"()
?
What is the integer row number? The desired answer would be 4
Note: I am aware this is circular, the ultimate goal is to put this into a formula to pick up another "cell" using relative navigation, e.g.
#pseudocode
def rowgetter(x)
priorvalue =frame.at[index[rownumber(x)-1],'level1']#pseudocode
priorvalue += 10 #or something
and then
rownmums=frame.level1.map(rowgetter)
Result would look like
nan(?)
30
29
30
31
35
39
40
41
40
39
The reason I'm asking this is that I can't get shift to work in a formula, but even if the question in the link is answered, I find this question interesting enough by itself.