calliope-project / calliope

A multi-scale energy systems modelling framework
https://www.callio.pe
Apache License 2.0
277 stars 89 forks source link

Handle different date formats in clustering #562

Closed brynpickering closed 4 months ago

brynpickering commented 4 months ago

Fixes issue where a different datetime format is being used alongside clustering.

Oddly, if you use the exact=False flag in pandas.to_datetime it will manage 01/01/2050 00:00:00 with the format %Y-%m-%d %H:%M but not 01/01/2050. That is, the "inexact" nature of the timestamp string is that it is longer than the dateformat, not shorter.

Hence, I tack on 00:00:00 to the clustering dates before converting them to datetime.

Summary of changes in this pull request:

Reviewer checklist:

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (6db0657) 95.76% compared to head (cdb6c9b) 95.77%. Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #562 +/- ## ======================================= Coverage 95.76% 95.77% ======================================= Files 24 24 Lines 3566 3574 +8 Branches 777 714 -63 ======================================= + Hits 3415 3423 +8 Misses 86 86 Partials 65 65 ``` | [Files](https://app.codecov.io/gh/calliope-project/calliope/pull/562?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project) | Coverage Δ | | |---|---|---| | [src/calliope/preprocess/time.py](https://app.codecov.io/gh/calliope-project/calliope/pull/562?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project#diff-c3JjL2NhbGxpb3BlL3ByZXByb2Nlc3MvdGltZS5weQ==) | `96.07% <100.00%> (+0.33%)` | :arrow_up: |