Skip to main content

JSON Time Series

Documentation Status PyPI version

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 | COORDINATES
  • id: string or number to uniquely identify the series to use instead of the automatically assigned id.
  • name: string
  • units: string
  • records: 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, null
  • quality (optional): number (quality code) associated with value
  • annotation (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 of TimeSeries to 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)

Source distribution for json-timeseries 0.1.7
File Size Uploaded
json_timeseries-0.1.7.tar.gz 13.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for json-timeseries 0.1.7
File Interpreter ABI Platform
json_timeseries-0.1.7-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page