How to find the first Non-NAN data before Nan in one column in Pandas

Viewed 1162

For example, I have some data like this:

column = pd.Series([1,2,3,np.nan,4,np.nan,7])
print column

Executing the command, the result looks like:

0    1.0
1    2.0
2    3.0
3    NaN
4    4.0
5    NaN
6    7.0

Now I want to know what is the first value before each NaN value, such as 3.0 which is before the first NaN. And 4.0 is the result before the second NaN value. Is there any built-in function in pandas which can complete this or shall I write a for loop to do this?

2 Answers
Related