Skip to content

Fix datestring warning and index sorting in timeseries parsing#18

Merged
iantsednv merged 10 commits into
mainfrom
bugfix/SM-326/datestring_warning
May 4, 2026
Merged

Fix datestring warning and index sorting in timeseries parsing#18
iantsednv merged 10 commits into
mainfrom
bugfix/SM-326/datestring_warning

Conversation

@iantsednv
Copy link
Copy Markdown
Collaborator

Bugs fixed:

  • handle_pvsyst_results: added explicit format="%d/%m/%y %H:%M" to suppress UserWarning on every API call
  • handle_pvsyst_results and _handle_losstree_results: replaced data.index = data.index.sort_values() with data.sort_index(inplace=True) (old code sorted labels without reordering rows)

Tests added (test_handle_timeseries_parsing.py, 9 tests):

  • PVsyst: shape, day-first parsing, no warning emitted, sort alignment, file save
  • Loss tree: shape, ISO date parsing, sort alignment
  • Detailed TSV: shape

data["Start of period"] = pd.to_datetime(data["Start of period"])
data.set_index("Start of period", inplace=True)
data.index = data.index.sort_values()
data.sort_index(inplace=True)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data["date"] = pd.to_datetime(data["date"], utc=True).dt.tz_localize(None)
data["date"] = pd.to_datetime(
data["date"], format="%d/%m/%y %H:%M", utc=True
).dt.tz_localize(None)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the point of this PR, but why do we drop the tz from the index? I would have thought explicit UTC is better. Add a comment please

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed utc alltogether

data = pd.read_csv(g, sep=";", skiprows=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12])
data["date"] = pd.to_datetime(data["date"], utc=True).dt.tz_localize(None)
data["date"] = pd.to_datetime(
data["date"], format="%d/%m/%y %H:%M", utc=True
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really true that results are always in utc? I feel like this is not the case

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes SF API returns local time

iantsednv and others added 3 commits May 4, 2026 10:55
@iantsednv iantsednv merged commit da96979 into main May 4, 2026
14 checks passed
@javlor javlor deleted the bugfix/SM-326/datestring_warning branch May 5, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants