1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-04 11:30:57 +08:00

dataset performance optm

This commit is contained in:
Young
2020-12-05 17:00:23 +00:00
committed by you-n-g
parent 65902e424c
commit d2107c9957
4 changed files with 101 additions and 41 deletions

View File

@@ -55,6 +55,22 @@ def read_bin(file_path, start_index, end_index):
return series
def np_ffill(arr: np.array):
"""
forward fill a 1D numpy array
Parameters
----------
arr : np.array
Input numpy 1D array
"""
mask = np.isnan(arr.astype(np.float)) # np.isnan only works on np.float
# get fill index
idx = np.where(~mask, np.arange(mask.shape[0]), 0)
np.maximum.accumulate(idx, out=idx)
return arr[idx]
#################### Search ####################
def lower_bound(data, val, level=0):
"""multi fields list lower bound.