DataSeries - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


Overview of DataSeries

 

Description

Indexing

Examples

Description

• 

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.

Indexing

• 

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

(1)
> 

ds[ 2 ];

cos⁡x

(2)
> 

ds[ 'c' ];

cos⁡x

(3)
• 

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

(4)
> 

ds[ 'c' .. 't' ];

ccos⁡xttan⁡x

(5)
• 

Note that indices and labels can be used together:

> 

ds[ 'c' .. -1 ];

ccos⁡xttan⁡x

(6)
• 

You can select non-contiguous entries by enclosing the desired indices in a list.

> 

ds[ [ 's', 't' ] ];

ssin⁡xttan⁡x

(7)
• 

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

(8)

Examples

> 

ds≔DataSeries⁡4,5,6,labels=a,b,c

ds≔a4b5c6

(9)
> 

type⁡ds,DataSeries

true

(10)
> 

type⁡ds,Array

false

(11)
> 

ds1

4

(12)
> 

dsb

5

(13)
> 

ds >~ 4;

afalsebtruectrue

(14)
> 

ds[ ds >~ 4 ];

b5c6

(15)

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

oct27_28≔12:00Typesetting:-_Hold⁡Temperature⁡11,Units:-Unit⁡degC,113:00Typesetting:-_Hold⁡Temperature⁡12,Units:-Unit⁡degC,114:00Typesetting:-_Hold⁡Temperature⁡13,Units:-Unit⁡degC,115:00Typesetting:-_Hold⁡Temperature⁡12,Units:-Unit⁡degC,116:00Typesetting:-_Hold⁡Temperature⁡11,Units:-Unit⁡degC,117:00Typesetting:-_Hold⁡Temperature⁡10,Units:-Unit⁡degC,118:00Typesetting:-_Hold⁡Temperature⁡9,Units:-Unit⁡degC,119:00Typesetting:-_Hold⁡Temperature⁡8,Units:-Unit⁡degC,120:00Typesetting:-_Hold⁡Temperature⁡7,Units:-Unit⁡degC,121:00Typesetting:-_Hold⁡Temperature⁡7,Units:-Unit⁡degC,1⋮⋮24 element DataSeries

(16)

Compute the average temperature over this 24-hour period.

> 

avg≔add⁡oct27_28numelems⁡oct27_28

avg≔698⁢°C

(17)
> 

Value⁡avg

698

(18)

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

(19)

Converting a DataSeries to a set only shows the unique elements:

> 

convert⁡oct27_28,set

11⁢°C,7⁢°C,8⁢°C,9⁢°C,10⁢°C,13⁢°C,12⁢°C

(20)

Converting to a table is the only conversion that attempts to maintain information on labels:

> 

convert⁡oct27_28,table

table⁡10:00=9⁢°C,05:00=8⁢°C,20:00=7⁢°C,11:00=10⁢°C,21:00=7⁢°C,04:00=7⁢°C,03:00=7⁢°C,18:00=9⁢°C,19:00=8⁢°C,02:00=7⁢°C,06:00=8⁢°C,01:00=7⁢°C,16:00=11⁢°C,07:00=8⁢°C,17:00=10⁢°C,00:00=7⁢°C,13:00=12⁢°C,23:00=7⁢°C,14:00=13⁢°C,08:00=7⁢°C,12:00=11⁢°C,15:00=12⁢°C,22:00=7⁢°C,09:00=8⁢°C

(21)

See Also

DataFrame

DataSeries/Constructor