Skip to content

Commit

Permalink
chore(interpolation): change back to bfill, change forward to ffill
Browse files Browse the repository at this point in the history
  • Loading branch information
guanjieshen committed Jan 14, 2022
1 parent 45f6087 commit 015879b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ Interpolate a series to fill in missing values using a specified function. The f

- Zero Fill : `zero`
- Null Fill: `null`
- Backwards Fill: `back`
- Forwards Fill: `forward`
- Backwards Fill: `bfill`
- Forwards Fill: `ffill`
- Linear Fill: `linear`

This method automatically first re-samples the input dataset into a given frequency, then performs interpolation on the sampled time-series dataset
Expand Down
4 changes: 2 additions & 2 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ Interpolate a series to fill in missing values using a specified function. The f

- Zero Fill : `zero`
- Null Fill: `null`
- Backwards Fill: `back`
- Forwards Fill: `forward`
- Backwards Fill: `bfill`
- Forwards Fill: `ffill`
- Linear Fill: `linear`

This method automatically first re-samples the input dataset into a given frequency, then performs interpolation on the sampled time-series dataset
Expand Down
8 changes: 4 additions & 4 deletions python/tempo/interpol.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pyspark.sql.window import Window

# Interpolation fill options
method_options = ["zero", "null", "back", "forward", "linear"]
method_options = ["zero", "null", "bfill", "ffill", "linear"]
supported_target_col_types = ["int", "bigint", "float", "double"]


Expand All @@ -15,7 +15,7 @@ def __validate_fill(self, method: str):
"""
Validate if the fill provided is within the allowed list of values.
:param fill - Fill type e.g. "zero", "null", "back", "forward", "linear"
:param fill - Fill type e.g. "zero", "null", "bfill", "ffill", "linear"
"""
if method not in method_options:
raise ValueError(
Expand Down Expand Up @@ -137,7 +137,7 @@ def __interpolate_column(
)

# Handle forward fill
if method == "forward":
if method == "ffill":
output_df = output_df.withColumn(
target_col,
when(
Expand All @@ -146,7 +146,7 @@ def __interpolate_column(
).otherwise(col(target_col)),
)
# Handle backwards fill
if method == "back":
if method == "bfill":
output_df = output_df.withColumn(
target_col,
# Handle case when subsequent value is null
Expand Down
2 changes: 1 addition & 1 deletion python/tempo/tsdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ def interpolate(self, freq: str, func: str, method: str, target_cols: List[str]
:param freq: frequency for upsample - valid inputs are "hr", "min", "sec" corresponding to hour, minute, or second
:param func: function used to aggregate input
:param method: function used to fill missing values e.g. linear, null, zero, back, forward
:param method: function used to fill missing values e.g. linear, null, zero, bfill, ffill
:param target_cols [optional]: columns that should be interpolated, by default interpolates all numeric columns
:param ts_col [optional]: specify other ts_col, by default this uses the ts_col within the TSDF object
:param partition_cols [optional]: specify other partition_cols, by default this uses the partition_cols within the TSDF object
Expand Down
4 changes: 2 additions & 2 deletions python/tests/interpol_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def test_back_fill_interpolation(self):
freq="30 seconds",
ts_col="event_ts",
func="mean",
method="back",
method="bfill",
show_interpolated=True,
)

Expand Down Expand Up @@ -303,7 +303,7 @@ def test_forward_fill_interpolation(self):
freq="30 seconds",
ts_col="event_ts",
func="mean",
method="forward",
method="ffill",
show_interpolated=True,
)

Expand Down

0 comments on commit 015879b

Please sign in to comment.