airbornegeo.interpolate_missing_pointwise_with_windows

airbornegeo.interpolate_missing_pointwise_with_windows#

interpolate_missing_pointwise_with_windows(data, *, window_width, to_interp, interp_on, method='cubic', extrapolate=False, fill_value=None, groupby_column=None, progressbar=True)[source]#

Interpolate NaN’s in the “to_interp” column, based on values from “interp_on” using only values within a window around the NaN. If groupby_column is provided, the dataframe will first be grouped by this so only data from the group containing the NaN is used to interpolate.

To interpolate multiple columns, call this function once per column.

For each NaN, the requested method is tried first, expanding the window if there aren’t enough points, before falling back through the hierarchy method -> ‘linear’ -> ‘nearest’. See _interpolate_missing_pointwise_with_windows for details.

Parameters:
  • data (DataFrame) – Dataframe containing the data to interpolate

  • window_width (float) – width of data window around NaN value to use in the interpolation, in units of the data provided in the column interp_on

  • to_interp (str) – Column to interpolate

  • interp_on (str) – Column to interpolate on

  • method (str) – Interpolation method to use, by default “cubic”

  • extrapolate (bool) – Whether to extrapolate beyond the data range, by default False

  • fill_value (tuple[float, float] | str | None) – Value to use for filling gaps, by default None

  • groupby_column (str | None) – Column name to group by before interpolating, by default None

  • progressbar (bool) – Show progress bar for each group, by default True

Returns:

Dataframe with interpolated column

Return type:

DataFrame