DataSeries/AreUnique
determine unique elements in a DataSeries
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
AreUnique( data )
data
-
DataSeries
options
options : (optional) equation(s) of the form option=value where option can be any of keep.
keep : first, last, none; if a duplicate element is encountered, keep specifies which duplicate to retain
The AreUnique command returns a DataSeries of type truefalseFAIL where the elements correspond to true if the given element is unique and false if the given element is a duplicate of another value in the given DataSeries.
The output from the AreUnique command can be used to index a DataSeries or DataFrame in order to return the unique rows in a given column.
The keep option allows for specification of which duplicate element value in the DataSeries to keep. By default, keep marks the first instance of a value that it encounters as unique (true) and marks any duplicates of this first instance as a duplicate (false). If keep is set to last, the last detected duplicate value is marked as unique (true) and any other matching values are marked as duplicate (false). If keep is set to none, any elements that have duplicates are marked as duplicates (false).
DS≔DataSeries⁡1,2,3,3,4,5,5,5
DS≔1122334354657585
The AreUnique command returns a truefalseFAIL DataSeries that shows all unique values as true.
AreUnique⁡DS
1true2true3true4false5true6true7false8false
If the DataSeries is indexed by the result, a filtered DataSeries is returned that removes any duplicate values:
DSAreUnique⁡DS
1122335465
The results can be used to index a DataFrame and remove the rows that have duplicate values in a specific column.
DF≔DataFrame⁡1,1,2,3,3,4|5,3,6,2,1,4|6,5,1,4,9,9|4,2,1,7,8,3
DF≔1234115642135232611432475319864493
AreUnique⁡DF1
1true2false3true4true5false6true
The keep option allows for specification of which row to keep, either the first, last or none, when a duplicate is found:
DFAreUnique⁡DF1,keep=first
123411564326114324764493
DFAreUnique⁡DF1,keep=last
123421352326115319864493
If keep is set to none, all rows that have a duplicate value in a column are marked as false.
DFAreUnique⁡DF1,keep=none
12343261164493
The DataSeries/AreUnique command was introduced in Maple 2016.
For more information on Maple 2016 changes, see Updates in Maple 2016.
See Also
AreDuplicate
type/truefalseFAIL
Download Help Document