Change Datatype of Column Entries - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


DataFrame/SubsDatatype

change the datatype for a column in a DataFrame

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

SubsDatatype( DF, index, newdatatype, options )

Parameters

DF

-

a DataFrame object

index

-

name, string or integer value; specifies the column index for the chosen column

newdatatype

-

type; the new datatype for the given column

Options

• 

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

Description

• 

The SubsDatatype command changes the datatype of the entries in a given column of a DataFrame as well as the indicated datatype of the column.

• 

Internally, the DataFrame/SubsDatatype command uses the DataSeries/SubsDatatype command to change the datatype.

• 

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.

genusRubus,Vitis,Fragaria:

energy220,288,136:

carbohydrates11.94,18.1,7.68:

top_producerRussia,China,USA:

berriesDataFrameenergy|carbohydrates|top_producer|genus,columns=Energy,Carbohydrates,`Top Producer`,Genus,rows=Raspberry,Grape,Strawberry,datatypes=integer,float,anything,string

berriesEnergyCarbohydratesTop ProducerGenusRaspberry22011.9400000000000RussiaRubusGrape28818.1000000000000ChinaVitisStrawberry1367.68000000000000USAFragaria

(1)

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

Datatypesberries

integer,float8,anything,string

(2)

You can change the datatype of the Energy column to float:

SubsDatatypeberries,Energy,float

EnergyCarbohydratesTop ProducerGenusRaspberry220.11.9400000000000RussiaRubusGrape288.18.1000000000000ChinaVitisStrawberry136.7.68000000000000USAFragaria

(3)

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

berriesSubsDatatypeberries,Energy,float

berriesEnergyCarbohydratesTop ProducerGenusRaspberry220.11.9400000000000RussiaRubusGrape288.18.1000000000000ChinaVitisStrawberry136.7.68000000000000USAFragaria

(4)

DatatypeberriesEnergy

float8

(5)

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

berriesSubsDatatypeberries,Genus,name,`=`conversion,xconvertx,name

berriesEnergyCarbohydratesTop ProducerGenusRaspberry220.11.9400000000000RussiaRubusGrape288.18.1000000000000ChinaVitisStrawberry136.7.68000000000000USAFragaria

(6)

berriesSubsDatatypeberries,`Top Producer`,string,`=`conversion,xconvertx,string

berriesEnergyCarbohydratesTop ProducerGenusRaspberry220.11.9400000000000RussiaRubusGrape288.18.1000000000000ChinaVitisStrawberry136.7.68000000000000USAFragaria

(7)

Datatypesberries

float8,float8,string,name

(8)

Compatibility

• 

The DataFrame/SubsDatatype command was introduced in Maple 2017.

• 

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

See Also

DataFrame/Datatypes

DataSeries/Datatype

DataSeries/SubsDatatype