I am new to working with Python and have the following problem with my calculations.
I have a table which contains NaN values.
The NaN values always occur at night, because no solar radiation can be measured there.
I want to replace all NaN values from a night with the value 4 hours before sunset.
I already tried to use the Ffill command, but since I don't need the last value before the NaN values, it doesn't work unfortunately.
For example:
a=[0.88, 0.84, 0.26, 0.50, 1.17, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.73, 0.81]
The successive NaN values should all have the value 0.84.
The list should therefore look like this:
a=[0.88, 0.84, 0.26, 0.50, 1.17, 0.84, 0.84, 0.84, 0.84, 0.84, 0.84, 0.84, 0.84, 0.73, 0.81]
Thanks in advance.