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

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.

genusDataSeriesRubus,Vitis,Fragaria,labels=Raspberry,Grape,Strawberry,datatype=string:

energyDataSeries220,288,136,labels=Raspberry,Grape,Strawberry,datatype=integer:

carbohydratesDataSeries11.94,18.1,7.68,labels=Raspberry,Grape,Strawberry,datatype=float:

top_producerDataSeriesRussia,China,USA,labels=Raspberry,Grape,Strawberry,datatype=name:

The individual DataSeries are displayed more compactly in a DataFrame:

berriesDataFrameEnergy=energy,Carbohydrates=carbohydrates,TopProducer=top_producer,Genus=genus

berriesEnergyCarbohydratesTopProducerGenusRaspberry22011.9400000000000RussiaRubusGrape28818.1000000000000ChinaVitisStrawberry1367.68000000000000USAFragaria

(1)

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

Datatypesberries

integer,float8,name,string

(2)

Datatypecarbohydrates

float8

(3)

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

SubsDatatypeenergy,float

Raspberry220.Grape288.Strawberry136.

(4)

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

energySubsDatatypeenergy,float

energyRaspberry220.Grape288.Strawberry136.

(5)

Datatypeenergy

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:

genusSubsDatatypegenus,name,`=`conversion,xconvertx,name

genusRaspberryRubusGrapeVitisStrawberryFragaria

(7)

Datatypegenus

name

(8)

top_producerSubsDatatypetop_producer,string,`=`conversion,xconvertx,string

top_producerRaspberryRussiaGrapeChinaStrawberryUSA

(9)

Datatypetop_producer

string

(10)

berriesDataFrameEnergy=energy,Carbohydrates=carbohydrates,TopProducer=top_producer,Genus=genus

berriesEnergyCarbohydratesTopProducerGenusRaspberry220.11.9400000000000RussiaRubusGrape288.18.1000000000000ChinaVitisStrawberry136.7.68000000000000USAFragaria

(11)

Datatypesberries

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