pad_dataframe_to_frequency#

API documentation for tradingstrategy.utils.forward_fill.pad_dataframe_to_frequency Python function.

pad_dataframe_to_frequency(df, freq, end_timestamp)[source]#

Pads a Pandas DataFrame with NaN entries for all columns up to a given end timestamp, using the inferred frequency of the DataFrame.

  • Also sets forward_filled column to True/False for generated rows.

Parameters:
  • df (DataFrame) – The Pandas DataFrame to pad. Must have a DatetimeIndex.

  • freq (pandas._libs.tslibs.offsets.DateOffset | str) – The frequency to pad with.

  • end_timestamp (Timestamp) – The timestamp to pad the DataFrame up to.

Returns:

A new Pandas DataFrame with NaN entries added to the end, such that the DataFrame extends to the end_timestamp with the given frequency.

Return type:

DataFrame