Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Commit

Permalink
update unpack_intervals to include entity_id arg
Browse files Browse the repository at this point in the history
  • Loading branch information
signekb authored Mar 13, 2023
1 parent 6b09aa7 commit 1cd3b7f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/psycop_feature_generation/loaders/raw/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def unpack_intervals(
df: pd.DataFrame,
starttime_col: str = "datotid_start_sei",
endtime_col: str = "timestamp",
entity_id: str = "dw_ek_borger",
unpack_freq: str = "D",
) -> pd.DataFrame:
"""Transform df with starttime_col and endtime_col to day grain (one row per day in the interval starttime_col-endtime_col).
Expand Down Expand Up @@ -321,7 +322,7 @@ def unpack_intervals(

# concat df with start and end time rows
df = pd.concat([df, df_end_rows], ignore_index=True).sort_values(
["dw_ek_borger", f"{starttime_col}", "date_range"]
[f"{entity_id}", f"{starttime_col}", "date_range"]
)

# drop duplicates (when start and/or end time = 00:00:00)
Expand All @@ -334,7 +335,7 @@ def unpack_intervals(
df["value"] = 1

# only keep relevant columns and rename date_range to timestamp
df = df[["dw_ek_borger", "date_range", "value"]].rename(
df = df[[f"{entity_id}", "date_range", "value"]].rename(
columns={"date_range": "timestamp"}
)

Expand Down

0 comments on commit 1cd3b7f

Please sign in to comment.