tsfuse.data

class tsfuse.data.Collection(x, column_id='id', column_sort='time', tags=None, unit=None)

Data structure for representing time series data and attribute-value data.

Parameters
  • x (pandas.DataFrame) – Time series or attributes given as a DataFrame.

  • column_id (str, default: 'id') – Name of the column that contains the instance identifiers.

  • column_sort (str, default: 'time') – Name of the column that contains the timestamps.

  • tags (optional) – Tags specified by keys and values.

  • unit (optional) – Unit, see the Pint documentation.

values

Three-dimensional array of shape (N, t, d) containing the values of the time series data.

Type

numpy.array

shape

Shape (N, t, d) of the tme series data.

Type

numpy.array

tags

Tags specified by keys and values.

Type

tsfuse.data.Tags

unit

Unit of the time series data.

Type

pint.unit.Unit

to_dataframe(id='id', time='time')

Convert to a DataFrame.

Parameters
  • id (str, default: 'id') – Name of the column with the instance identifiers.

  • time (str, default: 'time') – Name of the column with the timestamps.

class tsfuse.data.Tags(tags=None)

Mapping of tag keys to values.

A tag is assigned to a unit of data and describes the contents of this data item. Each tag has a key and corresponding value. Possible tags are the sample rate, the sensor type and the location of the sensor. tsfuse defines a couple of standardized tags (see tsfuse.data.tags.TagKey), but it is also possible to define your own custom tags.

Parameters

tags (dict, optional) – Dictionary where each key is a tsfuse.data.tags.TagKey instance and each value is in the domain of the key.

Raises

InvalidTagError – If the given tag value is not valid for one of the keys.

Examples

>>> from tsfuse.data import Tags, TagKey
>>> tags = Tags({TagKey.QUANTITY: 'acceleration'})
add(key, value)

Add a new tag.

Parameters
  • key (TagKey) – The key to identify the tag.

  • value (int, float or str) – The value of the tag. The value should be valid, i.e., the value should be in the tag’s domain.

Raises

InvalidTagException – If the given value is not valid for the given key.

Examples

>>> tags = Tags()
>>> tags.add(TagKey.QUANTITY, 'acceleration')
get(key)

Return the value for a given tag key.

Parameters

key (TagKey or str) – The key of the tag to retrieve.

Returns

Tag value or None if the tag key does not exist.

Return type

value

remove(key)

Remove a tag with a given key.

Parameters

key (TagKey or str) – The key of the tag to remove.

Raises

KeyError – If no tag with key key exists.

check(*tags)

Check whether a set of tags is included in this collection.

Parameters

*tags ((key, value)) – Key-value pairs to check for.

Returns

checkedTrue if all key-value pairs exist.

Return type

boolean

intersect(other)

Return the intersection of two Tags instances as a new Tags instance. The intersection consists of all (key, value) pairs that occur in both Tags instances.

Parameters

other (Tags) – Other Tags instance.

Returns

intersection

Return type

Tags