I am having weird problem. I have a numpy array which contain data corresponding to different dates (in date list). I also have separate list with truncate date in it for each row. Now, I need to replace the value in numpy array with NaN, if the date is less than truncate date for that row. Example below.
import numpy as np
date = ['01-05-2020', '02-05-2020', '03-05-2020', '04-05-2020', '05-05-2020', '06-05-2020', '07-05-2020', '08-05-2020', '09-05-2020', '10-05-2020']
a = np.random.rand(4,10)
truncate_date = ['01-05-2020', '04-05-2020', '06-05-2020', '06-05-2020']
My Output a would look like:
([[0.954637 0.403668 0.63196 0.143053 0.86481 0.119429 0.266624 0.672866 0.902944 0.241125]
[np.NaN np.NaN np.NaN 0.0207699 0.165715 0.0354149 0.944116 0.759993 0.942923 0.56149]
[np.NaN np.NaN np.NaN np.NaN np.NaN 0.65055 0.948541 0.256155 0.207642 0.600534]
[np.NaN np.NaN np.NaN np.NaN np.NaN 0.431788 0.387213 0.285412 0.770842 0.657336]])
Unfortunately, I am clueless to approach. Not sure if this can be done.