Skip to content

Commit e777179

Browse files
Putting back the implementation
1 parent 99b9bdf commit e777179

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

datareservoirio/client.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,6 @@ def get(
395395
pandas.Series
396396
Series data
397397
"""
398-
start_provided = start is not None
399-
end_provided = end is not None
400-
401398
if not start:
402399
start = _START_DEFAULT
403400
if not end:
@@ -433,19 +430,22 @@ def get(
433430
else:
434431
df = pd.DataFrame(columns=("index", "values")).astype({"index": "int64"})
435432

436-
s = df.set_index("index").squeeze("columns")
437-
438-
# Ensure sorted (cheap if already sorted)
439-
if not s.index.is_monotonic_increasing:
433+
try:
434+
# When we move to pandas 3, the .loc here breaks with None start and end, haven't dug into why yet
435+
series = (
436+
df.set_index("index").squeeze("columns").loc[start:end].copy(deep=True)
437+
)
438+
except KeyError as e:
440439
logging.warning(
441440
"The time series you requested is not properly ordered. The data will be sorted to attempt to resolve the issue. Please note that this operation may take some time."
442441
)
443-
s = s.sort_index()
444-
445-
series = s.loc[
446-
start if start_provided else None : end if end_provided else None
447-
].copy(deep=True)
448-
442+
series = (
443+
df.set_index("index")
444+
.sort_index()
445+
.squeeze("columns")
446+
.loc[start:end]
447+
.copy(deep=True)
448+
)
449449
series.index.name = None
450450

451451
if series.empty and raise_empty: # may become empty after slicing

0 commit comments

Comments
 (0)