Overview of DataSeries - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : DataFrames and DataSeries : DataSeries

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' ] );

dsssinxccosxttanx

(1)

ds[ 2 ];

cosx

(2)

ds[ 'c' ];

cosx

(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 ];

ssinxccosx

(4)

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

ccosxttanx

(5)
• 

Note that indices and labels can be used together:

ds[ 'c' .. -1 ];

ccosxttanx

(6)
• 

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

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

ssinxttanx

(7)
• 

One particular application for this kind of index is to re-order the given DataSeries.

ds2 := ds[ [ 2, 3, 1 ] ];

ds2ccosxttanxssinx

(8)

Examples

dsDataSeries4,5,6,'labels'='a','b','c'

dsa4b5c6

(9)

typeds,DataSeries

true

(10)

typeds,'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_28DataSeriesmapTemperature,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

(16)

Compute the average temperature over this 24-hour period.

avgaddoct27_28numelemsoct27_28

avg698°C

(17)

Valueavg

698

(18)

DataSeries objects can be converted to an Array, Vector, Matrix, table, list, or set:

convertoct27_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:

convertoct27_28,'set'

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

(20)

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

convertoct27_28,'table'

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

(21)

See Also

DataFrame

DataSeries/Constructor