Skip to content

Commit

Permalink
Drop invalid values before updating model.data_years (#290)
Browse files Browse the repository at this point in the history
Use @SamRWest suggestion from #217 as a temporary fix
  • Loading branch information
olejandro authored Jan 17, 2025
1 parent 2385280 commit 1e466ab
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions xl2times/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down

0 comments on commit 1e466ab

Please sign in to comment.