mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-16 17:12:20 +08:00
simplify the code and prevent float when shifting
This commit is contained in:
@@ -237,7 +237,7 @@ class CacheUtils:
|
|||||||
lock.acquire()
|
lock.acquire()
|
||||||
except redis_lock.AlreadyAcquired:
|
except redis_lock.AlreadyAcquired:
|
||||||
raise QlibCacheException(
|
raise QlibCacheException(
|
||||||
f"""It sees the key(lock:{repr(lock_name)[1:-1]}-wlock) of the redis lock has existed in your redis db now.
|
f"""It sees the key(lock:{repr(lock_name)[1:-1]}-wlock) of the redis lock has existed in your redis db now.
|
||||||
You can use the following command to clear your redis keys and rerun your commands:
|
You can use the following command to clear your redis keys and rerun your commands:
|
||||||
$ redis-cli
|
$ redis-cli
|
||||||
> select {C.redis_task_db}
|
> select {C.redis_task_db}
|
||||||
@@ -784,10 +784,10 @@ class DiskDatasetCache(DatasetCache):
|
|||||||
def build_index_from_data(data, start_index=0):
|
def build_index_from_data(data, start_index=0):
|
||||||
if data.empty:
|
if data.empty:
|
||||||
return pd.DataFrame()
|
return pd.DataFrame()
|
||||||
line_data = data.iloc[:, 0].fillna(0).groupby("datetime").count()
|
line_data = data.groupby("datetime").size()
|
||||||
line_data.sort_index(inplace=True)
|
line_data.sort_index(inplace=True)
|
||||||
index_end = line_data.cumsum()
|
index_end = line_data.cumsum()
|
||||||
index_start = index_end.shift(1).fillna(0)
|
index_start = index_end.shift(1, fill_value=0)
|
||||||
|
|
||||||
index_data = pd.DataFrame()
|
index_data = pd.DataFrame()
|
||||||
index_data["start"] = index_start
|
index_data["start"] = index_start
|
||||||
|
|||||||
Reference in New Issue
Block a user