tslearn.utils.ts_size

tslearn.utils.ts_size(ts)[source]

Returns actual time series size.

Final timesteps that have NaN values for all dimensions will be removed from the count. Infinity and negative infinity ar considered valid time series values.

Parameters:
ts : array-like

A time series.

Returns:
int

Actual size of the time series.

Examples

>>> ts_size([1, 2, 3, numpy.nan])
3
>>> ts_size([1, numpy.nan])
1
>>> ts_size([numpy.nan])
0
>>> ts_size([[1, 2],
...          [2, 3],
...          [3, 4],
...          [numpy.nan, 2],
...          [numpy.nan, numpy.nan]])
4
>>> ts_size([numpy.nan, 3, numpy.inf, numpy.nan])
3

Examples using tslearn.utils.ts_size