mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-17 01:14:35 +08:00
simplify the code and prevent float when shifting
This commit is contained in:
@@ -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