Skip to content

Commit caafafe

Browse files
EliEli
authored andcommitted
Force index to have a name when written from update_repo.
1 parent d79cb51 commit caafafe

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

dms_datastore/read_multi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from dms_datastore.filename import build_repo_globs, interpret_fname
1010
from vtools.functions.merge import ts_merge, ts_splice
1111
from vtools.functions.unit_conversions import *
12+
from vtools.data.vtime import compare_interval
1213

1314
__all__ = ["read_ts_repo", "ts_multifile_read", "resolve_providers_for_repo"]
1415

@@ -361,7 +362,7 @@ def ts_multifile(
361362
tsfreq = ts.index.freq if hasattr(ts.index, "freq") else None
362363
if commonfreq is None:
363364
commonfreq = tsfreq
364-
elif compare_intervals(tsfreq, commonfreq) < 0:
365+
elif compare_interval(tsfreq, commonfreq) < 0:
365366
print(
366367
f"frequency change detected from {commonfreq} to {tsfreq} within pattern"
367368
)

dms_datastore/reconcile_data.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ def _write_preserving_header(
407407
os.makedirs(os.path.dirname(dest_path) or ".", exist_ok=True)
408408
if header_text and not header_text.endswith("\n"):
409409
header_text = header_text + "\n"
410+
if df.index.name is None:
411+
df.index.name = "datetime"
410412
with open(dest_path, "w", encoding="utf-8", newline="\n") as f:
411413
if header_text:
412414
f.write(header_text)
@@ -1169,6 +1171,8 @@ def update_repo(
11691171
head = extract_commented_header(a.staged_path)
11701172

11711173
df = _read_csv_timeseries(a.staged_path)
1174+
if df.index.name is None:
1175+
df.index.name = "datetime"
11721176
_write_preserving_header(df=df, dest_path=a.repo_path, header_text=head)
11731177

11741178
elif a.action == "splice_write":

0 commit comments

Comments
 (0)