tsa.update#
- mainsource.update(name, updatets, author, metadata=None, insertion_date=None, keepnans=False, **kw)#
Update a series named by <name> with the input pandas series.
This creates a new version of the series. Only the _changes_ between the last version and the provided series are part of the new version.
A series made of the changed points is returned. If there was no change, an empty series is returned and no new version is created.
New points are added, changed points are changed, points with NaN are dropped if keepnans is False (by default) or _erased_ if True.
The author is mandatory. The metadata dictionary allows to associate any metadata with the new series revision.
It is possible to force an insertion_date, which can only be higher than the previous insertion_date.
>>> import pandas as pd >>> from tshistory.api import timeseries >>> >>> tsa = timeseries('postgres://me:password@localhost/mydb') >>> >>> series = pd.Series([1, 2, 3], ... pd.date_range(start=pd.Timestamp(2017, 1, 1), ... freq='D', periods=3)) # db insertion >>> tsa.update('my_series', series, 'babar@pythonian.fr') ... 2017-01-01 1.0 2017-01-02 2.0 2017-01-03 3.0 Freq: D, Name: my_series, dtype: float64
- Parameters:
name (str)
updatets (Series)
author (str)
metadata (dict | None)
insertion_date (datetime | None)
keepnans (bool | None)
- Return type:
Series | None