Select, Remove - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


DataFrame/select

selection from a DataFrame

DataFrame/remove

removal from a DataFrame

DataFrame/selectremove

selection and removal from a DataFrame

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

select(f, DF, key, b1, ..., bn)

select[inplace](f, DF, key, b1, ..., bn)

remove(f, DF, key, b1, ..., bn)

remove[inplace](f, DF, key, b1, ..., bn)

selectremove(f, DF, key, b1, ..., bn)

selectremove[inplace](f, DF, key, b1, ..., bn)

Parameters

f

-

Boolean-valued procedure

DF

-

a DataFrame object

key

-

specifies the key column of DF

b1, ..., bn

-

(optional) extra arguments for f

Description

• 

When called on a DataFrame object, the select command returns a DataFrame object consisting of those rows where the key column entry satisfies the given criterion.

• 

When called on a DataFrame object, the remove command returns a DataFrame object consisting of those rows where the key column entry does not satisfy the given criterion.

• 

When called on a DataFrame object, the selectremove command returns a sequence of two DataFrame objects, the first consisting of those rows where the key column entry satisfies the given criterion, and the second consisting of the other rows.

• 

The commands can also be called on other types of arguments. This behavior is described on the main help page for select.

• 

The criterion used for deciding whether a row of the DataFrame is included in the result is to call fx,b1,...,bn, where x is the entry in that row and in the key column. This should return true or false (or FAIL, which is interpreted in the same way as false). If you call select, then the returned DataFrame will contain this row if and only if the value returned is true. If you call remove, then the returned DataFrame will contain this row if and only if the value returned is false (or FAIL).

• 

The value key can be a positive or negative integer to indicate the position of the key column, or the label of the key column. This is interpreted in the same way as for indexing a DataFrame, so the first test is if key is a valid column position, and if not, the second test is whether it is a valid column label. You cannot specify a range, list, rtable, or Boolean DataSeries or DataFrame.

• 

Any row that is included in the result will have the same label that it has in DF. All columns have the same labels as in DF.

• 

If you call select[inplace] or remove[inplace], the command will modify the DataFrame object DF and return it. The calling sequences with no index on the command name will return a new DataFrame object and leave DF unchanged. If you call selectremove[inplace], then the command will modify DF to be the first DataFrame returned, and the second DataFrame will be a new DataFrame object.

• 

You can do similar things with DataFrame indexing using a Boolean DataSeries. See the example below. Indexing also allows for criteria involving multiple columns, which is not supported with the select, remove, and selectremove commands.

Examples

We split df, below, into rows with prime and non-prime entries in various ways, using the isprime command as the testing criterion.

dfDataFrameMatrix4,5,i,j2ij,rows=a,b,c,d,columns=A,B,C,D,E

dfABCDEa10−1−2−3b3210−1c54321d76543

(1)

The rows for which the first column is a prime.

selectisprime,df,1

ABCDEb3210−1c54321d76543

(2)

We can get the same result if we specify the first column with its label, A.

selectisprime,df,A

ABCDEb3210−1c54321d76543

(3)

A third way to get the same result is by indexing with a Boolean DataSeries.

df`~`isprimedfA

ABCDEb3210−1c54321d76543

(4)

We can obtain the rows where the entries in column D are non-prime using remove.

removeisprime,df,D

ABCDEa10−1−2−3b3210−1d76543

(5)

If we want to obtain both the rows where the entries are prime, and where they are nonprime, we can use selectremove. Below, we show this for column C.

selectremoveisprime,df,C

ABCDEc54321d76543,ABCDEa10−1−2−3b3210−1

(6)

If we want to select the entries of a particular type, then we can use the optional fourth argument to select.

selecttype,df,C,positive

ABCDEb3210−1c54321d76543

(7)

The original DataFrame, df, is unchanged, because we used the commands without the inplace index.

df

ABCDEa10−1−2−3b3210−1c54321d76543

(8)

If we call select with the inplace index, then df is modified in-place.

selectinplacetype,df,C,positive

ABCDEb3210−1c54321d76543

(9)

df

ABCDEb3210−1c54321d76543

(10)

Compatibility

• 

The DataFrame/select, DataFrame/remove and DataFrame/selectremove commands were introduced in Maple 2019.

• 

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

See Also

DataFrame

DataFrame/Constructor

main help page for select