I am about few weeks old with Python. I am new to both object oriented and Python. My experience is limited to COBOL.
I can iterate over the df in the old fashioned clumsy way using nested for-loop, but I'm sure there is an elegant way out.
mydf:
DataFrame with index and 4 cols. datetime, close, crossover, NearestCrossoverClose:
The crossover column has Y in case my technical analysis line has crossed over Until the next crossover happens this col has NaN values
I need to get the value of close associated with Crossover=Y and following Crossover=NaN into the NearestCrossoverClose=the value of the close when the last crossover took place.
PS: It could be nearest=1 (first nearest crossover close) or nearest=n integer. Default is 1.