How to replace numpy NaNs by last non-NaN value

Usebottleneck.push:

replace_nans_bottleneck.py
import bottleneck

y = bottleneck.push(y, axis=0)

If not installed already, you can install bottleneck using

install_bottleneck.py
pip install bottleneck

 


Check out similar posts by category: Python