1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-10 14:26:56 +08:00

fix some small bug

This commit is contained in:
Young
2020-11-14 08:23:19 +00:00
parent ea5f14ce12
commit 7a79028a72
6 changed files with 40 additions and 17 deletions

View File

@@ -185,7 +185,7 @@ def get_cls_kwargs(config: Union[dict, str], module) -> (type, dict):
if isinstance(config, dict):
# raise AttributeError
klass = getattr(module, config["class"])
kwargs = config["kwargs"]
kwargs = config.get("kwargs", {})
elif isinstance(config, str):
klass = getattr(module, config)
kwargs = {}
@@ -619,6 +619,28 @@ def exists_qlib_data(qlib_dir):
return True
def lexsort_index(df: pd.DataFrame) -> pd.DataFrame:
"""
make the df index lexsorted
df.sort_index() will take a lot of time even when `df.is_lexsorted() == True`
This function could avoid such case
Parameters
----------
df : pd.DataFrame
Returns
-------
pd.DataFrame:
sorted dataframe
"""
if df.index.is_lexsorted():
return df
else:
return df.sort_index()
#################### Wrapper #####################
class Wrapper(object):
"""Data Provider Wrapper"""