Overview of DataSeries
Description
Indexing
Examples
A DataSeries is a one-dimensional data container, similar to a one-dimensional Array, but whose entries can be referenced by "labels", as well as by position.
A related two-dimensional data container, known as a DataFrame is also available.
You can access the elements of a DataSeries similar to the way in which you access Array elements, by indexing the DataSeries by position. If ds is a DataSeries, then ds[ i ] evaluates to the ith element of ds. However, the elements of a DataSeries are also associated with symbolic names, and you can use these names to refer to DataSeries elements as well.
ds := DataSeries( [ sin( x ), cos( x ), tan( x ) ], 'labels' = [ 's', 'c', 't' ] );
ds≔ssin⁡xccos⁡xttan⁡x
ds[ 2 ];
cos⁡x
ds[ 'c' ];
To select a range of entries in a DataSeries, returning the result as a DataSeries, use a range of indices or labels.
ds[ 1 .. 2 ];
ssin⁡xccos⁡x
ds[ 'c' .. 't' ];
ccos⁡xttan⁡x
Note that indices and labels can be used together:
ds[ 'c' .. -1 ];
You can select non-contiguous entries by enclosing the desired indices in a list.
ds[ [ 's', 't' ] ];
ssin⁡xttan⁡x
One particular application for this kind of index is to re-order the given DataSeries.
ds2 := ds[ [ 2, 3, 1 ] ];
ds2≔ccos⁡xttan⁡xssin⁡x
ds≔DataSeries⁡4,5,6,labels=a,b,c
ds≔a4b5c6
type⁡ds,DataSeries
true
type⁡ds,Array
false
ds1
4
dsb
5
ds >~ 4;
afalsebtruectrue
ds[ ds >~ 4 ];
b5c6
Hourly temperatures reported by the BlackBerry Weather App for Waterloo, Ontario on October 27/28 2015.
oct27_28≔DataSeries⁡map⁡Temperature,11,12,13,12,11,10,9,8,7,7,7,7,7,7,7,7,7,8,8,8,7,8,9,10,degC,labels=12:00,13:00,14:00,15:00,16:00,17:00,18:00,19:00,20:00,21:00,22:00,23:00,00:00,01:00,02:00,03:00,04:00,05:00,06:00,07:00,08:00,09:00,10:00,11:00
Compute the average temperature over this 24-hour period.
avg≔add⁡oct27_28numelems⁡oct27_28
avg≔698⁢°C
Value⁡avg
698
DataSeries objects can be converted to an Array, Vector, Matrix, table, list, or set:
convert⁡oct27_28,list
11⁢°C,12⁢°C,13⁢°C,12⁢°C,11⁢°C,10⁢°C,9⁢°C,8⁢°C,7⁢°C,7⁢°C,7⁢°C,7⁢°C,7⁢°C,7⁢°C,7⁢°C,7⁢°C,7⁢°C,8⁢°C,8⁢°C,8⁢°C,7⁢°C,8⁢°C,9⁢°C,10⁢°C
Converting a DataSeries to a set only shows the unique elements:
convert⁡oct27_28,set
8⁢°C,7⁢°C,9⁢°C,10⁢°C,13⁢°C,12⁢°C,11⁢°C
Converting to a table is the only conversion that attempts to maintain information on labels:
convert⁡oct27_28,table
table⁡18:00=9⁢°C,09:00=8⁢°C,19:00=8⁢°C,08:00=7⁢°C,20:00=7⁢°C,13:00=12⁢°C,07:00=8⁢°C,12:00=11⁢°C,21:00=7⁢°C,06:00=8⁢°C,05:00=8⁢°C,22:00=7⁢°C,15:00=12⁢°C,04:00=7⁢°C,14:00=13⁢°C,23:00=7⁢°C,10:00=9⁢°C,03:00=7⁢°C,00:00=7⁢°C,17:00=10⁢°C,02:00=7⁢°C,11:00=10⁢°C,16:00=11⁢°C,01:00=7⁢°C
See Also
DataFrame
DataSeries/Constructor
Download Help Document