Find Duplicate Rows - Maple Help

DataFrame/AreDuplicate

determine duplicate rows in a DataFrame

 Calling Sequence AreDuplicate( data )

Parameters

 data -

 Description The AreDuplicate command returns a DataSeries of type truefalseFAIL where the elements correspond to true if the corresponding row has duplicates in the DataSeries and false if the row is unique. The output from the AreDuplicate command can be used to index a DataFrame in order to return the duplicate rows.

Examples

The following DataFrame has one duplicate row; the fourth row is the same as the first.

 > $\mathrm{DF}≔\mathrm{DataFrame}\left(⟨⟨1,1,2,1,3,4⟩|⟨6,5,1,6,9,9⟩|⟨4,2,1,4,8,3⟩⟩\right)$
 ${\mathrm{DF}}{≔}\left[\begin{array}{cccc}{}& {1}& {2}& {3}\\ {1}& {1}& {6}& {4}\\ {2}& {1}& {5}& {2}\\ {3}& {2}& {1}& {1}\\ {4}& {1}& {6}& {4}\\ {5}& {3}& {9}& {8}\\ {6}& {4}& {9}& {3}\end{array}\right]$ (1)

The AreDuplicate command returns a truefalseFAIL DataSeries that shows duplicate rows as true and unique rows as false.

 > $\mathrm{AreDuplicate}\left(\mathrm{DF}\right)$
 $\left[\begin{array}{cc}{1}& {\mathrm{true}}\\ {2}& {\mathrm{false}}\\ {3}& {\mathrm{false}}\\ {4}& {\mathrm{true}}\\ {5}& {\mathrm{false}}\\ {6}& {\mathrm{false}}\end{array}\right]$ (2)

If the DataFrame is indexed by the result, a filtered DataFrame is returned that shows just the duplicate rows:

 > $\mathrm{DF}\left[\mathrm{AreDuplicate}\left(\mathrm{DF}\left[1\right]\right)\right]$
 $\left[\begin{array}{cccc}{}& {1}& {2}& {3}\\ {1}& {1}& {6}& {4}\\ {2}& {1}& {5}& {2}\\ {4}& {1}& {6}& {4}\end{array}\right]$ (3)

This can also be combined with other queries in order to show rows that meet a given criteria. For example, to see which rows have duplicate elements in the first column and whose entries in the second column are less than 6:

 > DF[ AreDuplicate( DF[1] ) and DF[2] <~ 6 ];
 $\left[\begin{array}{cccc}{}& {1}& {2}& {3}\\ {2}& {1}& {5}& {2}\end{array}\right]$ (4)

Compatibility

 • The DataFrame/AreDuplicate command was introduced in Maple 2016.