Skip to content

Commit

Permalink
Corrected the issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcdermott committed May 13, 2024
1 parent 68f7d51 commit 4837e49
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/esgpt_task_querying/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,6 @@ def boolean_expr_bound_sum(
│ 2 ┆ 1989-12-08 16:22:00 ┆ 1989-12-04 13:14:00 ┆ 1989-12-05 16:22:00 ┆ 0 ┆ 0 ┆ 0 │
│ 2 ┆ 1989-12-10 03:07:00 ┆ 1989-12-04 13:14:00 ┆ 1989-12-07 03:07:00 ┆ 1 ┆ 1 ┆ 1 │
└────────────┴─────────────────────┴─────────────────────┴─────────────────────┴──────┴──────┴──────┘
>>> print(df)
TODO: HERE AND BELOW!!!
>>> boolean_expr_bound_sum(
... df,
... pl.col("idx").is_in([1, 4, 7]),
Expand All @@ -951,14 +949,16 @@ def boolean_expr_bound_sum(
│ i64 ┆ datetime[μs] ┆ datetime[μs] ┆ datetime[μs] ┆ u16 ┆ u16 ┆ u16 │
╞════════════╪═════════════════════╪═════════════════════╪═════════════════════╪══════╪══════╪══════╡
│ 1 ┆ 1989-12-01 12:03:00 ┆ null ┆ null ┆ 0 ┆ 0 ┆ 0 │
│ 1 ┆ 1989-12-03 13:14:00 ┆ 1989-12-03 13:14:00 ┆ 1989-12-03 13:14:00 ┆ 0 ┆ 11
│ 1 ┆ 1989-12-05 15:17:00 ┆ 1989-12-03 13:14:00 ┆ 1989-12-05 15:17:00 ┆ 111
│ 2 ┆ 1989-12-02 12:03:00 ┆ null ┆ null ┆ 000
│ 2 ┆ 1989-12-04 13:14:00 ┆ 1989-12-04 13:14:00 ┆ 1989-12-04 13:14:00 ┆ 100
│ 2 ┆ 1989-12-06 15:17:00 ┆ 1989-12-04 13:14:00 ┆ 1989-12-06 15:17:00 ┆ 2 ┆ 1 ┆ 1 │
│ 2 ┆ 1989-12-08 16:22:00 ┆ 1989-12-04 13:14:00 ┆ 1989-12-08 16:22:00 ┆ 221
│ 2 ┆ 1989-12-10 03:07:00 ┆ 1989-12-10 03:07:00 ┆ 1989-12-10 03:07:00 ┆ 0 ┆ 11
│ 1 ┆ 1989-12-03 13:14:00 ┆ null ┆ null ┆ 0 ┆ 00
│ 1 ┆ 1989-12-05 15:17:00 ┆ null ┆ null ┆ 000
│ 2 ┆ 1989-12-02 12:03:00 ┆ 1989-12-05 12:03:00 ┆ 1989-12-10 03:07:00 ┆ 132
│ 2 ┆ 1989-12-04 13:14:00 ┆ 1989-12-07 13:14:00 ┆ 1989-12-10 03:07:00 ┆ 021
│ 2 ┆ 1989-12-06 15:17:00 ┆ 1989-12-09 15:17:00 ┆ 1989-12-10 03:07:00 ┆ 0 ┆ 1 ┆ 1 │
│ 2 ┆ 1989-12-08 16:22:00 ┆ null ┆ null ┆ 000
│ 2 ┆ 1989-12-10 03:07:00 ┆ null ┆ null ┆ 0 ┆ 00
└────────────┴─────────────────────┴─────────────────────┴─────────────────────┴──────┴──────┴──────┘
>>> print(df)
TODO: HERE AND BELOW!!!
>>> boolean_expr_bound_sum(
... df,
... pl.col("idx").is_in([1, 4, 7]),
Expand Down Expand Up @@ -1122,7 +1122,10 @@ def boolean_expr_bound_sum(
).alias(c)
for c in cols
}
if closed in ("left", "both"):
if (closed in ("left", "both") and offset <= timedelta(0)) or offset < timedelta(0):
# If we either do include the left endpoint due to the closed value and the lack of a positive
# offset or we have a negative offset, we want to add in the left endpoint's (the row's) counts
# As they will always be included.
sum_exprs = {c: expr + pl.col(c) for c, expr in sum_exprs.items()}

at_boundary_df = df.filter(boundary_expr).select(
Expand Down

0 comments on commit 4837e49

Please sign in to comment.