From 83a8b0580205d02c378ddded84a115c2a1d7fa8d Mon Sep 17 00:00:00 2001 From: Gourav Kumar Date: Sun, 10 Apr 2022 13:27:25 +0530 Subject: [PATCH] implemented setitem --- fincal/core.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fincal/core.py b/fincal/core.py index 474f2b4..fe04a8c 100644 --- a/fincal/core.py +++ b/fincal/core.py @@ -364,6 +364,11 @@ class TimeSeriesCore(UserDict): raise TypeError(f"Invalid type {repr(type(key).__name__)} for slicing.") + def __setitem__(self, key: str | datetime.datetime, item: Number) -> None: + key = _parse_date(key) + super().__setitem__(key, item) + self.data = dict(sorted(self.data.items())) + def __iter__(self): self.n = 0 return self