I'm trying to cast a series of 20 values at the end of a dataframe with more than 20 rows.
The original values are coming from a numpy array 'Y_pred':
[[3495.47227957]
 [3493.27865109]
 [3491.08502262]
 [3488.89139414]
 [3486.69776567]
 [3484.50413719]
 [3482.31050871]
 [3480.11688024]
 [3477.92325176]
 [3475.72962329]
 [3473.53599481]
 [3471.34236633]
 [3469.14873786]
 [3466.95510938]
 [3464.7614809 ]
 [3462.56785243]
 [3460.37422395]
 [3458.18059548]
 [3455.986967  ]
 [3453.79333852]]
creating column Y_pred and trying to cast the converted series:
df['Y_pred'] = np.nan
df.Y_pred.iloc[-len(Y_pred):].append(pd.Series({'Y_pred': Y_pred}), ignore_index=True)
result is that all rows are NaN
I tried as well this:
series = pd.Series(Y_pred[:, 0])
df.Y_pred.iloc[-20:].append(series, ignore_index=True)
and
df['Y_pred'].append(Y_pred)
nothing works. How to do it properly?
