-
I have been playing around with resampling but decided to create a resampled data.close column through pandas for hourly from 5 min data from yahoo. I create a condition to check if not nan and to store that int in a variable to check against later in my trade logic. when I print the variable to see what is being stored, it seems to have stored all values including the nan's despite placing the conditional within the next method to ignore all nan values. I have tried to store specific row values from within the Next method previously in a different way and seemed to run into a similar issue. Am I missing something? example: when self.Hourly is printed on each iteration I get all values including nan confused! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Checking for nan should be done with >>> float('nan') == float('nan')
False
>>> import numpy as np
>>> np.nan == np.nan
False But more importantly, why not simply use >>> pd.Series([1, np.nan, np.nan, 2, np.nan]).ffill().tolist()
[1, 1, 1, 2, 2] |
Beta Was this translation helpful? Give feedback.
Checking for nan should be done with
numpy.isnan()
as nans are a particularly curious bunch:But more importantly, why not simply use
Series.ffill()
?