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" +