DataFrame/AreUnique
determine unique rows in a DataFrame
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
AreUnique( data )
data
-
DataFrame
options
options : (optional) equation(s) of the form option=value where option can be keep.
keep : first, last, none; if a duplicate row is encountered, keep specifies which duplicate row to mark as unique
The AreUnique command returns a DataSeries of type truefalseFAIL, where the elements correspond to true if the corresponding row is unique and false if the given row is a duplicate of another row in the given DataFrame.
The output from the AreUnique command can be used to index a DataSeries or DataFrame in order to return the unique rows.
The keep option controls how duplicate rows are handled. By default, keep marks the first instance of a row as unique (true) and marks all repeated rows of any previously marked unique rows as duplicate (false). If keep is set to last, the last detected duplicate row is marked as unique and all other repeated rows are marked as duplicates. If keep is set to none, all rows that have duplicates are marked as duplicate (false).
The following DataFrame has one duplicate row; the fourth row is the same as the first.
DF≔DataFrame⁡1,1,2,1,3,4|6,5,1,6,9,9|4,2,1,4,8,3
DF≔123116421523211416453986493
The AreUnique command returns a truefalseFAIL DataSeries that shows duplicate rows as false and unique rows as true.
AreUnique⁡DF
1true2true3true4false5true6true
If the DataFrame is indexed by the result, a filtered DataFrame is returned that removes any duplicate rows:
DFAreUnique⁡DF
12311642152321153986493
The keep option allows for specification of which row to keep (either the first, last or none) when a duplicate row is found:
DFAreUnique⁡DF,keep=first
DFAreUnique⁡DF,keep=last
12321523211416453986493
If keep is set to none, any row that has a duplicate is marked as a duplicate (false).
DFAreUnique⁡DF,keep=none
1232152321153986493
The AreUnique command can also be used on individual DataSeries in a DataFrame. This allows for the removal of the rows that have duplicate values in a specific column.
DFAreUnique⁡DF1,keep=first
1231164321153986493
The DataFrame/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