Skip to content

Commit

Permalink
run black
Browse files Browse the repository at this point in the history
  • Loading branch information
Nina Hu committed Apr 14, 2023
1 parent 8fe8d2f commit 9d06de8
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions python/tempo/tsdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,15 +871,26 @@ def asofJoin(
df = asofDF.df
left_ts_col = left_tsdf.ts_col
right_ts_col = right_tsdf.ts_col
tolerance_condition = df[left_ts_col].cast("double") - df[right_ts_col].cast("double") > tolerance
tolerance_condition = (
df[left_ts_col].cast("double") - df[right_ts_col].cast("double")
> tolerance
)

for right_col in right_columns:
# First set right non-timestamp columns to null for rows outside of tolerance band
if right_col != right_ts_col:
df = df.withColumn(right_col, f.when(tolerance_condition, f.lit(None)).otherwise(df[right_col]))
df = df.withColumn(
right_col,
f.when(tolerance_condition, f.lit(None)).otherwise(
df[right_col]
),
)

# Finally, set right timestamp column to null for rows outside of tolerance band
df = df.withColumn(right_ts_col, f.when(tolerance_condition, f.lit(None)).otherwise(df[right_ts_col]))
df = df.withColumn(
right_ts_col,
f.when(tolerance_condition, f.lit(None)).otherwise(df[right_ts_col]),
)
asofDF.df = df

return asofDF
Expand Down

0 comments on commit 9d06de8

Please sign in to comment.