Questions tagged [duplicates]

The "duplicates" tag concerns detecting and/or dealing with multiple instances of items in collections.

A duplicate is any re-occurrence of an item in a collection. This can be as simple as two identical strings in a list of strings, or multiple complex objects which are treated as the same object when compared to each other.

This tag may pertain to questions about preventing, detecting, removing, or otherwise dealing with unwanted duplicates, or adapting to safely allow duplicates.

15777 questions
33
votes
2 answers

How does AWS FIFO SQS deduplication ID work?

I'm trying to use the AWS SQS FIFO service together with an Elastic Beanstalk worker environment. Let's say I send a message with MessageDeduplicationId test, if I continue sending this exact message in the next 5 minutes, the message will be…
tehmaestro
  • 1,010
  • 2
  • 11
  • 21
33
votes
8 answers

Python: Rename duplicates in list with progressive numbers without sorting list

Given a list like this: mylist = ["name", "state", "name", "city", "name", "zip", "zip"] I would like to rename the duplicates by appending a number to get the following result: mylist = ["name1", "state", "name2", "city", "name3", "zip1",…
panofish
  • 7,578
  • 13
  • 55
  • 96
32
votes
4 answers

Removing duplicates with unique index

I inserted between two tables fields A,B,C,D, believing I had created a Unique Index on A,B,C,D to prevent duplicates. However I somehow simply made a normal index on those. So duplicates got inserted. It is 20 million record table. If I change my…
user3649739
  • 1,829
  • 2
  • 18
  • 28
31
votes
7 answers

Duplicate strings in a list and add integer suffixes to newly added ones

Suppose I have a list: l = ['a', 'b', 'c'] And its suffix list: l2 = ['a_1', 'b_1', 'c_1'] I'd like the desired output to be: out_l = ['a', 'a_1', 'b', 'b_2', 'c', 'c_3'] The result is the interleaved version of the two lists above. I can write…
user1330974
  • 2,500
  • 5
  • 32
  • 60
31
votes
3 answers

TransformException duplicate entry for common.annotations.Beta

This started when I added google-api-services-calendar. I am getting this error when trying to build: Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.transform.api.TransformException:…
Chad Bingham
  • 32,650
  • 19
  • 86
  • 115
31
votes
3 answers

How to abort INSERT operation in MySql trigger?

I have a table containing an url and a string representing its parameters. The problem is I want an url and a parameterstring to be the unique constraint for the table - aka no entries can have the same url AND parameter string. The parameter string…
johnrl
  • 873
  • 3
  • 14
  • 18
31
votes
14 answers

How do I find duplicates in an array and display how many times they occurred?

I'm working on a code that prints out duplicated integers from an array with the number of their occurrence. I'm not allowed to use LINQ, just a simple code. I think I'm so close but confused about how to get a correct output: class Program { …
sunflower
  • 501
  • 1
  • 4
  • 14
31
votes
10 answers

Using Binary Search with sorted Array with duplicates

I've been tasked with creating a method that will print all the indices where value x is found in a sorted array. I understand that if we just scanned through the array from 0 to N (length of array) it would have a running time of O(n) worst case. …
5StringRyan
  • 3,604
  • 5
  • 46
  • 69
30
votes
3 answers

Using LINQ to find duplicates across multiple properties

Given a class with the following definition: public class MyTestClass { public int ValueA { get; set; } public int ValueB { get; set; } } How can duplicate values be found in a MyTestClass[] array? For example, MyTestClass[] items = new…
CatBusStop
  • 3,347
  • 7
  • 42
  • 54
30
votes
3 answers

Counting duplicate values in Pandas DataFrame

I'm trying to count the number of duplicate values based on set of columns in a DataFrame. Example: print df Month LSOA code Longitude Latitude Crime type 0 2015-01 E01000916 -0.106453 51.518207 Bicycle theft 1 2015-01…
tales
  • 593
  • 2
  • 5
  • 12
30
votes
5 answers

How do I use SELECT GROUP BY in DataTable.Select(Expression)?

I try to remove the duplicate rows by select a first row from every group. For Example PK Col1 Col2 1 A B 2 A B 3 C C 4 C C I want a return: PK Col1 Col2 1 A B 3 …
J - C Sharper
  • 1,567
  • 7
  • 23
  • 36
29
votes
6 answers

How can I find same values in a list and group together a new list?

From this list: N = [1,2,2,3,3,3,4,4,4,4,5,5,5,5,5] I'm trying to create: L = [[1],[2,2],[3,3,3],[4,4,4,4],[5,5,5,5,5]] Any value which is found to be the same is grouped into it's own sublist. Here is my attempt so far, I'm thinking I should use…
Siii
  • 483
  • 1
  • 5
  • 10
29
votes
5 answers

Java Scanner class reading strings

I got the following code: int nnames; String names[]; System.out.print("How many names are you going to save: "); Scanner in = new Scanner(System.in); nnames = in.nextInt(); names = new String[nnames]; for (int i = 0; i < names.length; i++){ …
marcoamorales
  • 625
  • 2
  • 10
  • 13
29
votes
8 answers

Count duplicates records in Mysql table?

I have table with, folowing structure. tbl id name 1 AAA 2 BBB 3 BBB 4 BBB 5 AAA 6 CCC select count(name) c from tbl group by name having c >1 The query returning this result: AAA(2) duplicate BBB(3) duplicate CCC(1) not…
dido
  • 2,330
  • 8
  • 37
  • 54
29
votes
9 answers

How to remove duplicates from unsorted std::vector while keeping the original ordering using algorithms?

I have an array of integers that I need to remove duplicates from while maintaining the order of the first occurrence of each integer. I can see doing it like this, but imagine there is a better way that makes use of STL algorithms better? The…
WilliamKF
  • 41,123
  • 68
  • 193
  • 295