From 9ddc7af036e7dd204fdc4567e44a2542bc20407a Mon Sep 17 00:00:00 2001 From: Olexandr Balyk Date: Wed, 25 Dec 2024 19:30:51 -0500 Subject: [PATCH] Reduce the size of the UC table --- xl2times/transforms.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xl2times/transforms.py b/xl2times/transforms.py index 918b504..3d3dc15 100644 --- a/xl2times/transforms.py +++ b/xl2times/transforms.py @@ -3223,6 +3223,18 @@ def apply_final_fixup( tables[Tag.fi_t] = df.reset_index(drop=True) + if Tag.uc_t in tables.keys(): + df = tables[Tag.uc_t] + keep_cols.remove("year2") + keep_cols = keep_cols.union({"uc_n", "side"}) + df.dropna(subset="value", inplace=True) + drop_cols = [ + col for col in df.columns if col != "value" and col not in keep_cols + ] + df.drop(columns=drop_cols, inplace=True) + df = df.drop_duplicates(subset=list(keep_cols), keep="last") + tables[Tag.uc_t] = df.reset_index(drop=True) + return tables