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

Online Help

All Products    Maple    MapleSim


DataSeries/SubsDatatype

change the datatype of a data series

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

SubsDatatype( DS, newdatatype, options )

Parameters

DF

-

a DataSeries object

newdatatype

-

type; the new datatype for the data series

Options

• 

conversion : procedure; specifies a procedure to be mapped onto the elements in the given data series. This option is entered in the form conversion = procedure.

Description

• 

The SubsDatatype command changes the datatype of the entries in a DataSeries as well as the indicated datatype of the data series.

• 

If the conversion option is given, then the values in the DataSeries are converted by this conversion procedure. Otherwise, they are typically not modified, but there are exceptions. Internally, a new Array is constructed with the given datatype, and the current values are used to initialize this Array; this is the step where an automatic conversion could take place.

Examples

Consider some data on berries.

> 

genus≔DataSeries⁡Rubus,Vitis,Fragaria,labels=Raspberry,Grape,Strawberry,datatype=string:

> 

energy≔DataSeries⁡220,288,136,labels=Raspberry,Grape,Strawberry,datatype=integer:

> 

carbohydrates≔DataSeries⁡11.94,18.1,7.68,labels=Raspberry,Grape,Strawberry,datatype=float:

> 

top_producer≔DataSeries⁡Russia,China,USA,labels=Raspberry,Grape,Strawberry,datatype=name:

The individual DataSeries are displayed more compactly in a DataFrame:

> 

berries≔DataFrame⁡Energy=energy,Carbohydrates=carbohydrates,TopProducer=top_producer,Genus=genus

berries≔EnergyCarbohydratesTopProducerGenusRaspberry22011.9400000000000RussiaRubusGrape28818.1000000000000ChinaVitisStrawberry1367.68000000000000USAFragaria

(1)

You can get the data types for the columns with the Datatypes command.

> 

Datatypes⁡berries

integer,float8,name,string

(2)
> 

Datatype⁡carbohydrates

float8

(3)

You can change the datatype of the Energy data series to float:

> 

SubsDatatype⁡energy,float

Raspberry220.Grape288.Strawberry136.

(4)

This does not change the datatype in place. To permanently change the datatype:

> 

energy≔SubsDatatype⁡energy,float

energy≔Raspberry220.Grape288.Strawberry136.

(5)
> 

Datatype⁡energy

float8

(6)

When working with strings or name conversions, it may be necessary to supply an explicit  conversion for the values in the data series:

> 

genus≔SubsDatatype⁡genus,name,`=`⁡conversion,x↦convert⁡x,name

genus≔RaspberryRubusGrapeVitisStrawberryFragaria

(7)
> 

Datatype⁡genus

name

(8)
> 

top_producer≔SubsDatatype⁡top_producer,string,`=`⁡conversion,x↦convert⁡x,string

top_producer≔RaspberryRussiaGrapeChinaStrawberryUSA

(9)
> 

Datatype⁡top_producer

string

(10)
> 

berries≔DataFrame⁡Energy=energy,Carbohydrates=carbohydrates,TopProducer=top_producer,Genus=genus

berries≔EnergyCarbohydratesTopProducerGenusRaspberry220.11.9400000000000RussiaRubusGrape288.18.1000000000000ChinaVitisStrawberry136.7.68000000000000USAFragaria

(11)
> 

Datatypes⁡berries

float8,float8,string,name

(12)

Compatibility

• 

The DataSeries/SubsDatatype command was introduced in Maple 2017.

• 

For more information on Maple 2017 changes, see Updates in Maple 2017.

See Also

DataFrame/Datatypes

DataFrame/SubsDatatype

DataSeries/Datatype