Skip to content

Commit

Permalink
Update src/MEDS_tabular_automl/generate_summarized_reps.py
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
mmcdermott and coderabbitai[bot] authored May 27, 2024
1 parent 7fdc37d commit 4dd3cad
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/MEDS_tabular_automl/generate_summarized_reps.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ def _generate_summary(df: DF_T, window_size: str, agg: str) -> pl.LazyFrame:
│ 2 ┆ 2021-01-04 ┆ 0 ┆ 1 │
└────────────┴────────────┴──────────────────┴──────────────────┘
"""
assert agg in VALID_AGGREGATIONS, f"Invalid aggregation: {agg}"
assert agg.split("/")[0] in [
c.split("/")[0] for c in df.columns
], f"df is invalid, no column with prefix: `{agg.split('/')[0]}`"
if agg not in VALID_AGGREGATIONS:
raise ValueError(f"Invalid aggregation: {agg}. Valid options are: {VALID_AGGREGATIONS}")
if agg.split("/")[0] not in [c.split("/")[0] for c in df.columns]:
raise ValueError(f"DataFrame is invalid, no column with prefix: `{agg.split('/')[0]}`")

if window_size == "full":
out_df = df.groupby("patient_id").agg(
Expand Down

0 comments on commit 4dd3cad

Please sign in to comment.