added convert_index utility

This commit is contained in:
2026-06-03 13:41:25 +02:00
parent 02ce0b756b
commit 4215e34fe6
+7 -9
View File
@@ -35,23 +35,17 @@ class ArcticLibrary:
except adb.exceptions.NoSuchVersionException:
df = pd.DataFrame()
df.index = df.index.view("int64") # adb supports update only for timeseries indexes
df.index.name = "run"
convert_index(df, "int64")
return df
def set_data(self, symbol, df):
df.index = df.index.view("datetime64[ns]") # adb supports update only for timeseries indexes
df.index.name = "run"
convert_index(df, "datetime64[ns]")
self.lib.update(symbol, df)
def append_data(self, symbol, df):
df.index = df.index.view("datetime64[ns]") # adb supports update only for timeseries indexes
df.index.name = "run"
convert_index(df, "datetime64[ns]")
self.lib.append(symbol, df)
@@ -69,5 +63,9 @@ def encode_index(index):
ts = pd.Timestamp(index) # adb supports update only for timeseries indexes
return pd.Index([ts], name="run")
def convert_index(df, dtype):
df.index = df.index.view(dtype) # adb supports update only for timeseries indexes
df.index.name = "run"