@@ -346,40 +346,39 @@ def populate_series_output(
346346 ) from e
347347
348348 if (output_i .shape [0 ] - self .horizon ) == len (fit_val ):
349- output_i ["fitted_value" ].iloc [: - self .horizon ] = (
350- fit_val # Note: may need to do len(output_i) - (len(fit_val) + horizon) : -horizon
351- )
349+ output_i .loc [output_i .index [
350+ : - self .horizon ], "fitted_value" ] = fit_val # Note: may need to do len(output_i) - (len(fit_val) + horizon) : -horizon
352351 elif (output_i .shape [0 ] - self .horizon ) > len (fit_val ):
353352 logger .debug (
354353 f"Fitted Values were only generated on a subset ({ len (fit_val )} /{ (output_i .shape [0 ] - self .horizon )} ) of the data for Series: { series_id } ."
355354 )
356355 start_idx = output_i .shape [0 ] - self .horizon - len (fit_val )
357- output_i [ "fitted_value" ]. iloc [start_idx : - self .horizon ] = fit_val
356+ output_i . loc [ output_i . index [start_idx : - self .horizon ], "fitted_value" ] = fit_val
358357 else :
359- output_i [ "fitted_value" ]. iloc [start_idx : - self .horizon ] = fit_val [
360- - (output_i .shape [0 ] - self .horizon ) :
358+ output_i . loc [ output_i . index [start_idx : - self .horizon ], "fitted_value" ] = fit_val [
359+ - (output_i .shape [0 ] - self .horizon ):
361360 ]
362361
363362 if len (forecast_val ) != self .horizon :
364363 raise ValueError (
365364 f"Attempting to set forecast along horizon ({ self .horizon } ) for series: { series_id } , however forecast is only length { len (forecast_val )} "
366365 f"\n Please refer to the troubleshooting guide at { TROUBLESHOOTING_GUIDE } for resolution steps."
367366 )
368- output_i [ "forecast_value" ]. iloc [- self .horizon : ] = forecast_val
367+ output_i . loc [ output_i . index [- self .horizon :], "forecast_value" ] = forecast_val
369368
370369 if len (upper_bound ) != self .horizon :
371370 raise ValueError (
372371 f"Attempting to set upper_bound along horizon ({ self .horizon } ) for series: { series_id } , however upper_bound is only length { len (upper_bound )} "
373372 f"\n Please refer to the troubleshooting guide at { TROUBLESHOOTING_GUIDE } for resolution steps."
374373 )
375- output_i [ self . upper_bound_name ]. iloc [- self .horizon : ] = upper_bound
374+ output_i . loc [ output_i . index [- self .horizon :], self . upper_bound_name ] = upper_bound
376375
377376 if len (lower_bound ) != self .horizon :
378377 raise ValueError (
379378 f"Attempting to set lower_bound along horizon ({ self .horizon } ) for series: { series_id } , however lower_bound is only length { len (lower_bound )} "
380379 f"\n Please refer to the troubleshooting guide at { TROUBLESHOOTING_GUIDE } for resolution steps."
381380 )
382- output_i [ self . lower_bound_name ]. iloc [- self .horizon : ] = lower_bound
381+ output_i . loc [ output_i . index [- self .horizon :], self . lower_bound_name ] = lower_bound
383382
384383 self .series_id_map [series_id ] = output_i
385384 self .verify_series_output (series_id )
0 commit comments