Sorry if this question seems too for newbies but I've been looking for an answer I didn't find it.
So, I have a dataset with lots of NaN values and I've been working on some regressions to predict those nulls, and since the prediction is given as a numpy.ndarray, I've trying to fill the gaps of the columns with those arrays with no success.
I mean, the column is something like this:
['Records']
101 21
102 22
103 23
104 24
106 NaN
107 NaN
108 NaN
109 NaN
110 NaN
111 29
112 30
The array is:
y_pred = [25, 26, 27, 28]
So, fillna doesn't handle numpy arrays to do the job, and my attempts were set the array as dict, pandas column, etc. but nothing worked.
Also, the other issue is the lenght of the array which always will be different from the original column.
I appreciate your insights.
First is necessary same number of missing values like length of array, if want replace all missing values by all values of array:
If is possible length not matched create helper
Series
with filter by lengths and pass toSeries.fillna
:Here array has length < number of NaNs:
Here array has length > number of NaNs: