From 1e466ab7a6a1c45f22637d1d1144e0913b34ca55 Mon Sep 17 00:00:00 2001 From: Olexandr Balyk Date: Fri, 17 Jan 2025 06:57:44 -0500 Subject: [PATCH] Drop invalid values before updating model.data_years (#290) Use @SamRWest suggestion from #217 as a temporary fix --- xl2times/datatypes.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xl2times/datatypes.py b/xl2times/datatypes.py index 0ff044d1..6fa85ce0 100644 --- a/xl2times/datatypes.py +++ b/xl2times/datatypes.py @@ -262,8 +262,16 @@ def data_years(self) -> set[int]: for attributes in [self.attributes, self.uc_attributes]: if not attributes.empty: # Index of the year column with non-empty values - index = attributes["year"] != "" - data_years.update(attributes["year"][index].astype(int).values) + # index = attributes["year"] != "" + # data_years.update(attributes["year"][index].astype(int).values) + # TODO: Ensure that non-parseble vals don't get this far + int_years = attributes["year"].astype( + int, errors="ignore" + ) # leave non-parseable vals alone + int_years = [ + y for y in int_years if isinstance(y, int) + ] # remove non-parseable years + data_years.update(int_years) # Remove interpolation rules before return return {y for y in data_years if y >= 1000}