JSON Time Series
JSON Time Series (JTS specification) handling Python library - Time Series data construction, manipulation and serialisation.
Installation
pip install json-timeseries
Import or require module
from json_timeseries import TsRecord, TimeSeries, JtsDocument
Usage
from json_timeseries import TsRecord, TimeSeries, JtsDocument
from datetime import datetime
# Create Time Series
timeseries1 = TimeSeries(identifier='series_1', name='Series 1', data_type='NUMBER',
records=[
TsRecord(**{"timestamp": datetime.now(), "value": '1.23', "quality": 192, "annotation": 'comment'}),
TsRecord(**{"timestamp": datetime.now(), "value": '2.34', "quality": 245, "annotation": 'comment number 2'})])
timeseries2 = TimeSeries(identifier='series_2', name='Series 2', data_type='NUMBER', units="C",
records=TsRecord(timestamp=datetime.now(), value=1.11, quality=111, annotation="comment ts2 111")
)
# Add record(s)
timeseries1.insert(TsRecord(**{ timestamp: datetime.now(), value: 30 }))
# Output in JSON Time Series document format
jts_doc = JtsDocument([timeseries1, timeseries2])
json_str = jts_doc.toJSONString()
TimeSeries
TimeSeries is a class for constructing and manipulating a single dataset.
from json_timeseries import TsRecord, TimeSeries
from datetime import datetime
time_series = TimeSeries(identifier='series_2', name='Series 2', data_type='NUMBER', units="m/s",
records=TsRecord(timestamp=datetime.now(), value=1.11, quality=0, annotation="example comment")
)
Options
Optionally provide configuration used for certain output formats such as JTS Document.
data_type: data type of record value attribute.NUMBER | TEXT | TIME | COORDINATESid: string or number to uniquely identify the series to use instead of the automatically assigned id.name: stringunits: stringrecords: list of data records
Alternatively set later:
time_series.data_type = 'NUMBER'
time_series.id = 'Series_1'
time_series.name = 'My Series'
time_series.units = 'm/s'
TsRecord
TsRecord is a class for constructing and manipulating a single record.
from json_timeseries import TsRecord
from datetime import datetime
ts_record1 = TsRecord(timestamp=datetime.now(), value=1.11, quality=0, annotation="example comment")
# Or as dict of parameters using ** operator
ts_record2 = TsRecord(**{"timestamp": datetime.now(), "value": 1.11, "quality": 0, "annotation": 'example comment'})
Record attributes
Records require a timestamp and at least one attribute: value, quality or annotation
timestamp: date object. Type of datetime. e.g.datetime.now()value(optional): number, string, date, nullquality(optional): number (quality code) associated with valueannotation(optional): string description or comment related to the record
Methods
See full documentation.
Properties
See full documentation.
JTS Document
JtsDocument is a class for outputting TimeSeries in
JSON Time Series document format.
# Create a JTS Document from one or more timeseries
jts_document = JtsDocument(series=[timeseries1, timeseries2])
# Output series in JTS Document format
json_str = jts_document.toJSONString()
Options
series: array ofTimeSeriesto include in JTS Document
Methods
See full documentation.
Properties
See full documentation.
License
MIT
Metadata
Release files for json-timeseries 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| json_timeseries-0.1.7.tar.gz | 13.8 kB | Without provenance | Details for json_timeseries-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| json_timeseries-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for json_timeseries-0.1.7-py3-none-any.whl |
Total release size: 23.3 kB
Release files / json_timeseries-0.1.7.tar.gz
| Download URL | json_timeseries-0.1.7.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12addeb14d8a374fcef7ab05698b9cc43880e707c29bc83103d80414e29b602c
|
|
BLAKE2b-256 checksum How to use checksums |
d35405a8c8bf9bc8303a19dbec4a28f833bc47c7424832243b5e9f051bc02bb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / json_timeseries-0.1.7-py3-none-any.whl
| Download URL | json_timeseries-0.1.7-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6af2d7a31dfef4fa8e8417689003f6a32a5b5a4f0998cbc55d21eea6e0ce5e55
|
|
BLAKE2b-256 checksum How to use checksums |
62a408f3c790a722e76bd70cd6cefa07919de6c627b0794d417f648abcb29677
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Security for json-timeseries 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.