1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-10 22:36:55 +08:00

update TimeSeriesDataset

This commit is contained in:
Young
2020-12-03 14:51:21 +00:00
committed by you-n-g
parent d093afd684
commit 5d5f8c8868
8 changed files with 347 additions and 118 deletions

View File

@@ -622,9 +622,9 @@ def exists_qlib_data(qlib_dir):
return True
def lexsort_index(df: pd.DataFrame) -> pd.DataFrame:
def lazy_sort_index(df: pd.DataFrame, axis=0) -> pd.DataFrame:
"""
make the df index lexsorted
make the df index sorted
df.sort_index() will take a lot of time even when `df.is_lexsorted() == True`
This function could avoid such case
@@ -638,10 +638,11 @@ def lexsort_index(df: pd.DataFrame) -> pd.DataFrame:
pd.DataFrame:
sorted dataframe
"""
if df.index.is_lexsorted():
idx = df.index if axis == 0 else df.columns
if idx.is_monotonic_increasing:
return df
else:
return df.sort_index()
return df.sort_index(axis=axis)
def flatten_dict(d, parent_key="", sep="."):