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
60
votes
6 answers

How do I duplicate item when using jquery sortable?

I am using this method http://jqueryui.com/demos/sortable/#connect-lists to connect two lists that i have. I want to be able to drag from list A to list B but when the item is dropped, i need to keep the original one still in list A. I checked the…
odle
  • 5,172
  • 8
  • 29
  • 33
60
votes
12 answers

Duplicate each member in a list

I want to write a function that reads a list [1,5,3,6,...] and gives [1,1,5,5,3,3,6,6,...]. Any idea how to do it?
ariel
  • 2,637
  • 4
  • 20
  • 12
60
votes
3 answers

Eliminating duplicate values based on only one column of the table

My query: SELECT sites.siteName, sites.siteIP, history.date FROM sites INNER JOIN history ON sites.siteName = history.siteName ORDER BY siteName,date First part of the output: How can I remove the duplicates in siteName column? I want to…
Ned
  • 1,055
  • 9
  • 34
  • 58
58
votes
7 answers

Deleting rows that are duplicated in one column based on the conditions of another column

Here is an example of my data set; Date Time(GMT)Depth Temp Salinity Density Phosphate 24/06/2002 1000 1 33.855 0.01 24/06/2002 1000 45 33.827 0.01 01/07/2002 1000 10 13.26 33.104 24.873 …
helen.h
  • 943
  • 2
  • 7
  • 18
57
votes
9 answers

How to install python package with a different name using PIP

When installing a new python package with PIP, can I change the package name because there is another package with the same name? Or, how can I change the existing package's name?
user3562812
  • 1,751
  • 5
  • 20
  • 30
54
votes
7 answers

Find duplicated rows (based on 2 columns) in Data Frame in R

I have a data frame in R which looks like: | RIC | Date | Open | |--------|---------------------|--------| | S1A.PA | 2011-06-30 20:00:00 | 23.7 | | ABC.PA | 2011-07-03 20:00:00 | 24.31 | | EFG.PA | 2011-07-04 20:00:00 |…
user802231
  • 853
  • 2
  • 8
  • 10
54
votes
17 answers

Group objects by multiple properties in array then sum up their values

Grouping elements in array by multiple properties is the closest match to my question as it indeed groups objects by multiple keys in an array. Problem is this solution doesn't sum up the properties value then remove the duplicates, it instead nests…
Hal_9100
  • 773
  • 1
  • 7
  • 17
54
votes
3 answers

How to remove repeated elements in a vector, similar to 'set' in Python

I have a vector with repeated elements, and would like to remove them so that each element appears only once. In Python I could construct a Set from a vector to achieve this, but how can I do this in R?
ashim
  • 24,380
  • 29
  • 72
  • 96
53
votes
5 answers

Entity Framework. View return duplicate records

I use Entity Framework that contains view. And I have query: var data = this.context.vwRevenues .Where(x => x.revenue >= 0); .OrderByDescending(x => x.year) .ThenByDescending(x => x.month) .Take(10) .ToList(); This query returns…
Eugene Gluhotorenko
  • 3,094
  • 2
  • 33
  • 52
52
votes
11 answers

Check and return duplicates array php

I would like to check if my array has any duplicates and return the duplicated values in an array. I want this to be as efficient as possible. Example: $array = array( 1, 2, 2, 4, 5 ); function return_dup($array); // should return 2 $array2 =…
NVG
  • 3,248
  • 10
  • 40
  • 60
51
votes
4 answers

Pandas drop_duplicates method not working on dataframe containing lists

I am trying to use drop_duplicates method on my dataframe, but I am getting an error. See the following: error: TypeError: unhashable type: 'list' The code I am using: df = db.drop_duplicates() My DB is huge and contains strings, floats, dates,…
SLack A
  • 577
  • 1
  • 6
  • 7
50
votes
4 answers

Techniques for finding near duplicate records

I'm attempting to clean up a database that, over the years, had acquired many duplicate records, with slightly different names. For example, in the companies table, there are names like "Some Company Limited" and "SOME COMPANY LTD!". My plan was to…
Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
50
votes
8 answers

how to prevent adding duplicate keys to a javascript array

I found a lot of related questions with answers talking about for...in loops and using hasOwnProperty but nothing I do works properly. All I want to do is check whether or not a key exists in an array and if not, add it. I start with an empty array…
iamsar
  • 1,080
  • 2
  • 15
  • 28
49
votes
3 answers

Delete rows that exist in another data frame?

I have the two following data frames (example): df1: name profile type strand A 4.5 1 + B 3.2 1 + C 5.5 1 + D 14.0 1 - E 45.1 1 - F 32.8 …
biohazard
  • 2,017
  • 10
  • 28
  • 41
48
votes
16 answers

What's the best way to dedupe a table?

I've seen a couple of solutions for this, but I'm wondering what the best and most efficient way is to de-dupe a table. You can use code (SQL, etc.) to illustrate your point, but I'm just looking for basic algorithms. I assumed there would already…
froadie
  • 79,995
  • 75
  • 166
  • 235