From 8071a4058c0aa826c6a4eb8c13302d458b90d639 Mon Sep 17 00:00:00 2001 From: Jai Date: Tue, 6 Feb 2024 16:41:22 +0000 Subject: [PATCH] fixes #327 --- aeon/io/api.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/aeon/io/api.py b/aeon/io/api.py index 5c16159f..e0fafb89 100644 --- a/aeon/io/api.py +++ b/aeon/io/api.py @@ -2,7 +2,9 @@ import datetime from os import PathLike from pathlib import Path +import warnings +import numpy as np import pandas as pd """The duration of each acquisition chunk, in whole hours.""" @@ -138,15 +140,11 @@ def load(root, reader, start=None, end=None, time=None, tolerance=None, epoch=No _set_index(data) if start is not None or end is not None: try: - return data.loc[start:end] + start_idx, end_idx = np.where(data.index >= start)[0][0], np.where(data.index <= end)[0][-1] + return data.iloc[start_idx:end_idx] except KeyError: - import warnings - if not data.index.has_duplicates: warnings.warn(f"data index for {reader.pattern} contains out-of-order timestamps!") data = data.sort_index() - else: - warnings.warn(f"data index for {reader.pattern} contains duplicate keys!") - data = data[~data.index.duplicated(keep="first")] - return data.loc[start:end] + return data.iloc[start_idx:end_idx] return data