Skip to content

Commit 6acac54

Browse files
Windowing fix conforming to Pandas
1 parent 923f5a7 commit 6acac54

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

streamz/dataframe/aggregations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ def diff_loc(dfs, new, window=None):
209209
old = []
210210
if len(dfs) > 0:
211211
mx = max(df.index.max() for df in dfs)
212-
mn = mx - pd.Timedelta(window)
212+
mn = mx - pd.Timedelta(window) + pd.Timedelta('1ns')
213213
while pd.Timestamp(dfs[0].index.min()) < mn:
214-
o = dfs[0].loc[:mn - pd.Timedelta('1ns')]
214+
o = dfs[0].loc[:mn]
215215
old.append(o) # TODO: avoid copy if fully lost
216216
dfs[0] = dfs[0].iloc[len(o):]
217217
if not len(dfs[0]):

streamz/dataframe/tests/test_dataframes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,11 +755,11 @@ def f(x):
755755
assert len(L) == 5
756756

757757
first = df.iloc[:diff]
758-
first = first[first.index.max() - value - pd.Timedelta('1ns'):]
758+
first = first[first.index.max() - value + pd.Timedelta('1ns'):]
759759

760760
assert_eq(L[0], f(first))
761761

762-
last = df.loc[index.max() - value - pd.Timedelta('1ns'):]
762+
last = df.loc[index.max() - value + pd.Timedelta('1ns'):]
763763

764764
assert_eq(L[-1], f(last))
765765

0 commit comments

Comments
 (0)