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
41
votes
1 answer

What's the most Pythonic way to identify consecutive duplicates in a list?

I've got a list of integers and I want to be able to identify contiguous blocks of duplicates: that is, I want to produce an order-preserving list of duples where each duples contains (int_in_question, number of occurrences). For example, if I have…
machine yearning
  • 9,889
  • 5
  • 38
  • 51
41
votes
2 answers

Drop duplicates, keep most recent date in a Pandas dataframe

I have a Pandas dataframe containing two columns: a datetime column, and a column of integers representing station IDs. I need a new dataframe with the following modifications: For each set of duplicate STATION_ID values, keep the row with the most…
pjw
  • 2,133
  • 3
  • 27
  • 44
41
votes
2 answers

remove duplicate from string in PHP

I am looking for the fastest way to remove duplicate values in a string separated by commas. So my string looks like this; $str = 'one,two,one,five,seven,bag,tea'; I can do it be exploding the string to values and then compare, but I think it will…
Adnan
  • 25,882
  • 18
  • 81
  • 110
41
votes
3 answers

How to check for duplicate CSS rules?

I messed up my css and somehow i have a lot of the duplicate rules and my 1800 something lines css file is now of 3000+ lines.. Is there any way/tool that would take my css file as input and check for all the duplicate rules? and possibly generate a…
Alkshendra
  • 411
  • 1
  • 4
  • 5
41
votes
3 answers

Fastest Way to Drop Duplicated Index in a Pandas DataFrame

If I want to drop duplicated index in a dataframe the following doesn't work for obvious reasons: myDF.drop_duplicates(cols=index) and myDF.drop_duplicates(cols='index') looks for a column named 'index' If I want to drop an index I have to…
RukTech
  • 5,065
  • 5
  • 22
  • 23
41
votes
3 answers

Postgres: left join with order by and limit 1

I have the situation: Table1 has a list of companies. Table2 has a list of addresses. Table3 is a N relationship of Table1 and Table2, with fields 'begin' and 'end'. Because companies may move over time, a LEFT JOIN among them results in multiple…
40
votes
9 answers

how to avoid duplicates in a has_many :through relationship?

How can I achieve the following? I have two models (blogs and readers) and a JOIN table that will allow me to have an N:M relationship between them: class Blog < ActiveRecord::Base has_many :blogs_readers, :dependent => :destroy has_many…
Sebastian
  • 2,889
  • 4
  • 34
  • 37
40
votes
3 answers

Tree contains duplicate file entries

After some issues with our hosting, we decided to move our Git repository to GitHub. So I cloned the repository and tried pushing that to GitHub. However, I stumbled upon some errors we have never encountered before: C:\repositories\appName…
user1791257
  • 417
  • 1
  • 4
  • 3
40
votes
9 answers

duplicate symbols for architectures in Xcode

Here is the error message I receive when compiling ... Ld /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Products/Debug-iphonesimulator/MasterDetail.app/MasterDetail normal i386 cd…
IlyaKharlamov
  • 479
  • 1
  • 4
  • 10
39
votes
7 answers

Remove duplicates keeping entry with largest absolute value

Let's say I have four samples: id=1, 2, 3, and 4, with one or more measurements on each of those samples: > a <- data.frame(id=c(1,1,2,2,3,4), value=c(1,2,3,-4,-5,6)) > a id value 1 1 1 2 1 2 3 2 3 4 2 -4 5 3 -5 6 4 …
Stephen Turner
  • 2,574
  • 8
  • 31
  • 44
39
votes
3 answers

MySQL select rows that do not have matching column in other table

I can't seem to figure this out so far. I am trying to join two tables and only select the rows in table A that do not have a matching column in table B. For example, lets assume we have a users table and a sent table. users table has the following…
xendi
  • 2,332
  • 5
  • 40
  • 64
38
votes
6 answers

Remove duplicate CSS declarations across multiple files

I'm looking to remove duplicate CSS declarations from a number of files to make implementing changes easier. Is there a tool that can help me do that? Right now I'm faced with something like this: styles.css #content…
kotekzot
  • 1,518
  • 1
  • 14
  • 23
38
votes
8 answers

How to remove duplicate entries from a mysql db?

I have a table with some ids + titles. I want to make the title column unique, but it has over 600k records already, some of which are duplicates (sometimes several dozen times over). How do I remove all duplicates, except one, so I can add a UNIQUE…
user15063
38
votes
2 answers

NodeJS: How to remove duplicates from Array

I have an array: [ 1029, 1008, 1040, 1019, 1030, 1009, 1041, 1020, 1031, 1010, 1042, 1021, 1030, 1008, 1045, 1019, 1032, 1009, 1049, 1022, 1031, 1010, 1042, …
Yo Yo Saty Singh
  • 539
  • 1
  • 6
  • 15
38
votes
3 answers

How can I remove all duplicates so that NONE are left in a data frame?

There is a similar question for PHP, but I'm working with R and am unable to translate the solution to my problem. I have this data frame with 10 rows and 50 columns, where some of the rows are absolutely identical. If I use unique on it, I get one…
Lilith-Elina
  • 1,613
  • 4
  • 20
  • 31