mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-10 22:36:55 +08:00
fix some small bug
This commit is contained in:
@@ -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"""
|
||||
|
||||
Reference in New Issue
Block a user