Skip to content

Commit

Permalink
✨ Fill YEAR downstream l1->l2/l3
Browse files Browse the repository at this point in the history
  • Loading branch information
i-be-snek committed Nov 1, 2024
1 parent 0e88805 commit ccccc0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Database/fill_data_gap.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
args = parser.parse_args()
dg_util = DataGapUtils()
l1, l2, l3 = dg_util.load_data(input_dir=args.input_dir)
event_id, date_split = "Event_ID", "_Date_"
event_id, date_year_suffix = "Event_ID", "_Date_Year"

for event_id in list(l1[event_id].unique()):
replace_with_date = (
l1.loc[l1[event_id] == event_id][[x for x in l1.columns if date_split in x]].iloc[0].to_dict()
l1.loc[l1[event_id] == event_id][[x for x in l1.columns if date_year_suffix in x]].iloc[0].to_dict()
)

for level in [l2, l3]:
Expand Down
6 changes: 3 additions & 3 deletions Database/scr/normalize_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def load_data(self, input_dir: str) -> tuple[pd.DataFrame, dict[str, pd.DataFram

@staticmethod
def fill_date(row: dict, replace_with_date: dict):
date_cols = [x for x in row.keys() if "_Date_" in x]
if all([True if row[d] is None else False for d in date_cols]):
for c in date_cols:
year_cols = [x for x in row.keys() if "_Date_Year" in x]
if all([True if row[d] is None else False for d in year_cols]):
for c in year_cols:
row[c] = replace_with_date[c]
return row

Expand Down

0 comments on commit ccccc0b

Please sign in to comment.