Commit 284105e0 authored by Aurélien Campéas's avatar Aurélien Campéas
Browse files

make sure inserted series index contain no NaT

parent 064e3900ada1
......@@ -1493,3 +1493,13 @@ def test_insert_errors(engine, tsh):
with pytest.raises(AssertionError):
tsh.insert(engine, ts, 'error', 'Babar', metadata=42)
def test_index_with_nat(engine, tsh):
index = list(pd.date_range(start=utcdt(2018, 1, 1),
freq='D', periods=3))
index[1] = pd.NaT
ts = pd.Series([1, 2, 3], index=index)
with pytest.raises(AssertionError):
tsh.insert(engine, ts, 'index_with_nat', 'Bugger')
......@@ -59,6 +59,7 @@ class TimeSerie(SeriesServices):
isinstance(_insertion_date, datetime)), 'Bad format for insertion date'
assert not newts.index.duplicated().any(), 'There are some duplicates in the index'
assert newts.index.notna().all(), 'The index contains NaT entries'
if not newts.index.is_monotonic_increasing:
newts = newts.sort_index()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment