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
26
votes
2 answers

Error: [ngRepeat:dupes] what does this mean?

repeat directive outputing wine records from an api. I have a factory function to serve up the wine API which is then accessed in my controller app.factory("Wine", function ($http){ var factory = {}; //getWines factory.getWines =…
HGB
  • 2,157
  • 8
  • 43
  • 74
26
votes
3 answers

How can I remove duplicates in an array but keep the same order?

I have this cell array in MATLAB: y = { 'd' 'f' 'a' 'g' 'g' 'a' 'w' 'h'} I use unique(y) to get rid of the duplicates but it rearranges the strings in alphabetical order: >> unique(y) ans = 'a' 'd' 'f' 'g' 'h' 'w' I want to remove…
Ben Fossen
  • 1,331
  • 6
  • 21
  • 33
25
votes
9 answers

How to delete duplicates in SQL table based on multiple fields

I have a table of games, which is described as follows: +---------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra …
cfrederich
  • 1,790
  • 6
  • 26
  • 35
25
votes
9 answers

Remove duplicate items from an array

I use the line of code below to loop through a table in my database: $items_thread = $connection -> fetch_all($sql); And if I print the array out: print_r($items_thread); I will get this: Array ( [0] => Array ( …
Run
  • 54,938
  • 169
  • 450
  • 748
25
votes
4 answers

Removing Duplicates From Array of Custom Objects Swift

I have a custom class defined as follows : class DisplayMessage : NSObject { var id : String? var partner_image : UIImage? var partner_name : String? var last_message : String? var date : NSDate? } Now I have an array myChats = [DisplayMessage]?.…
Alk
  • 5,215
  • 8
  • 47
  • 116
25
votes
3 answers

Remove duplicates from a dataframe in PySpark

I'm messing around with dataframes in pyspark 1.4 locally and am having issues getting the dropDuplicates method to work. It keeps returning the error: "AttributeError: 'list' object has no attribute 'dropDuplicates'" Not quite sure why as I seem…
Jared
  • 2,904
  • 6
  • 33
  • 37
25
votes
2 answers

SQLAlchemy: Modification of detached object

I want to duplicate a model instance (row) in SQLAlchemy using the orm. My first thought was to do this: i = session.query(Model) session.expunge(i) old_id = i.id i.id = None session.add(i) session.flush() print i.id #New ID However, apparently…
EB.
  • 3,383
  • 5
  • 31
  • 43
25
votes
15 answers

PHP MySQL Copy a row within the same table... with a Primary and Unique key

My table has two keys, one is an auto incrementing id (PRIMARY), the other is the name of the item (UNIQUE). Is it possible to duplicate a row within this same table? I have tried: INSERT INTO items SELECT * FROM items WHERE id = '9198' This gives…
Norse
  • 5,674
  • 16
  • 50
  • 86
24
votes
4 answers

Non-Stop cronjob

I got a new requirement from the business about "real time" data/statistics. They want to show how our system is performing in real time. I am not sure how to do it but here are my thoughts: I don't think it's possible to get the data every seconds…
Gino Sullivan
  • 2,203
  • 18
  • 29
24
votes
3 answers

mysql insert on duplicate FIELD instead of KEY

------------------------------------- | user_id | user_name | user_visits | ------------------------------------- | 1 | foo | 5 | ------------------------------------- | 2 | bar | 12 …
pepsi600
  • 241
  • 1
  • 2
  • 3
24
votes
13 answers

More elegant way to check for duplicates in C++ array?

I wrote this code in C++ as part of a uni task where I need to ensure that there are no duplicates within an array: // Check for duplicate numbers in user inputted data int i; // Need to declare i here so that it can be accessed by the 'inner'…
Saladin Akara
  • 2,518
  • 6
  • 30
  • 50
24
votes
1 answer

remove duplicate values based on 2 columns

I want to remove duplicate values based upon matches in 2 columns in a dataframe, v2 & v4 must match between rows to be removed. > df v1 v2 v3 v4 v5 1 7 1 A 100 98 2 7 2 A 100 97 3 8 1 C NA 80 4 8 1 C 78 75 5 …
lmcshane
  • 1,074
  • 4
  • 14
  • 27
24
votes
3 answers

mongo 3 duplicates on unique index - dropDups

In the documentation for mongoDB it says: "Changed in version 3.0: The dropDups option is no longer available." Is there anything I can do (other than downgrading) if I actually want to create a unique index and destroy duplicate entries? please…
Alonzorz
  • 2,113
  • 4
  • 18
  • 21
23
votes
6 answers

How to persist @ManyToMany relation - duplicate entry or detached entity

I want to persist my entity with ManyToMany relation. But i have some problem during persisting process. My entities : @Entity @Table(name = "USER") public class User implements Serializable { private static final long serialVersionUID = 1L; …
Aure77
  • 3,034
  • 7
  • 33
  • 53
23
votes
2 answers

Eliminate duplicate rows in a PostgreSQL SELECT statement

This is my query: SELECT autor.entwickler,anwendung.name FROM autor left join anwendung on anwendung.name = autor.anwendung; entwickler | name ------------+------------- Benutzer 1 | Anwendung 1 Benutzer 2 | Anwendung 1 …
The Surrican
  • 29,118
  • 24
  • 122
  • 168