for i in range(1, len(forecast_data)):
forecast_data.loc[i, 'lag_gov'] = np.where(forecast_data.loc[i, 'DATE']<=last_actuals, forecast_data[i-1, 'gov_actual'], forecast_data.loc[i-1, 'gov_fcst'])
forecast_data.loc[i, 'lag_gov'] = pd.to_numeric(forecast_data.loc[i, 'lag_gov'], errors='coerce')
But the code is unable to convert the forecast_data.lag_gov to float. The result still shows it as an object.
Comments
Post a Comment