Skip to content

Commit

Permalink
Convert time slice to list of labels
Browse files Browse the repository at this point in the history
  • Loading branch information
dnerini committed May 28, 2024
1 parent c7f9685 commit 24337d5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mlpp_lib/model_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ def _time_partitioning(self) -> None:
for partition in self.partition_names:
idx = self._time_indexers[partition]
idx = pd.to_datetime(idx) # always convert to pandas datetime indices
idx = slice(*idx) if len(idx) == 2 else idx
if len(idx) == 2:
# convert slice to list of labels
time_index = pd.to_datetime(self.time_index)
idx = time_index[time_index.slice_indexer(start=idx[0], end=idx[1])]
indexer = {self.time_dim_name: idx}
if not hasattr(self, "partitions"):
self.partitions = {p: {} for p in self.partition_names}
Expand Down

0 comments on commit 24337d5

Please sign in to comment.