I have a dataset of 6 milion rows, the columns are: symbol, timeStamp, open price and close price. I run the following loop, which takes very long, though being very simple (if open price is nan, take close price from the previous row):
for i in range(0,len(price2)):
print(i)
if np.isnan(price3.iloc[i,2]):
price3.iloc[i,2]=price3.iloc[i-1,3]
How can I speed this loop up? As far as I know, I can change to apply(), but how can I include the if-condition to it?