Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
df = df.loc[df.index.notnull()]
assert df.index.is_monotonic_increasing, "Please sort your dataframe chronologically before calling search"
if df.empty:
return
threshold = min_data or df.index[0]
df, cutoff_time = cutoff_data(df=df, threshold=threshold)
if df.empty:
return
if isinstance(gap, int):
cutoff_time = df.index[0]
df = DataSlice(df)
df.context = DataSliceContext(slice_number=0, target_entity=self.target_entity)
def iloc(index, i):
if i < index.size:
return index[i]
while not df.empty and cutoff_time <= df.index[-1]:
if isinstance(self.window_size, int):
df_slice = df.iloc[:self.window_size]
window_end = iloc(df.index, self.window_size)
else:
window_end = cutoff_time + self.window_size
df_slice = df[:window_end]
# Pandas includes both endpoints when slicing by time.