From 4215e34fe65c8e4d1064ef5aef63d90bce51f2f0 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Wed, 3 Jun 2026 13:41:25 +0200 Subject: [PATCH] added convert_index utility --- stand/adb.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/stand/adb.py b/stand/adb.py index 618b855..5e46cdb 100644 --- a/stand/adb.py +++ b/stand/adb.py @@ -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" +