Replacing the last value after consecutive Nan
1 回表示 (過去 30 日間)
I would like to know how to replace a stand alone value that's greater than zero and follows a row of Nans. I would eventually replace that value with a 0.
For example, A = [ 0 0 0 Nan Nan Nan 1.2 0 0 Nan Nan 2.3 1 2 5], as you can see in A the value that I would want to replace by 0 is 1.2, I would like it to A = [ 0 0 0 Nan Nan Nan 0 0 0 Nan Nan 2.3 1 2 5]. I'm not sure how to approach this. Do I try to find the indices of the non nan values? and if I do that what would be next.
Help would be much appreciated.
Thank you in advance!