Questions tagged [set-difference]

The difference between two sets A and B consists of all elements that are in A but not in B.

Set difference is a mathematical operation defined on sets. It is also known as the relative complement of B with respect to A.
If we have two sets, say A and B, their difference A - B is the set of all elements that are in A but not in B.

Several programming languages have built-in features to remove a collection of elements from another collection of elements. When both collections are sets (meaning each element can occur at most once per collection and the order does not matter), this implements set difference.

Source: Wikipedia

197 questions
0
votes
1 answer

Hot to get the set difference of two 2d numpy arrays, or equivalent of np.setdiff1d in a 2d array?

Here Get intersecting rows across two 2D numpy arrays they got intersecting rows by using the function np.intersect1d. So i changed the function to use np.setdiff1d to get the set difference but it doesn't work properly. The following is the…
msunij
  • 309
  • 2
  • 8
0
votes
3 answers

How can I get the difference between two values in list

I'm trying to get the difference between temp1 and temp2 which will be 10.25.60.156 and 10.22.17.180 . Since the data in temp2 has brackets I've been receiving this error: z = set(temp1).symmetric_difference(set(temp2)) TypeError: unhashable type:…
Tom
  • 79
  • 1
  • 10
0
votes
1 answer

Django: How to compare two querysets and get the difference without including the PK

I don't think the word difference is correct because you might think difference() but it makes sense to me what I am trying to achieve. I do apologize if this is a common problem that's already been solved but I can't find a solution or dumbed down…
0
votes
1 answer

How to print uncommon value between 2 array?

I wanna compare value that stored in filename[i] and filename[j] and print out the value in filename[i] that do not have the same filename as in filename[j]. I know it is possible to do using set_difference and sort solution but I do not know…
0
votes
2 answers

How to print observations existing in one dataframe and missing from the other r?

I have a one dataframe with 3719 (actual data) rows and another with 3721 (from coding) rows. I got 2 extra observations. I have tried with setdiff but it is giving zero rows dplyr::setdiff(d1,d2) o/p: [1] col1 col2 col3 col4 [5] col5…
Navya
  • 307
  • 3
  • 15
0
votes
2 answers

Priority Queue union, intersection, difference compiling but not returning into output

My program prints the main constructor but is not returning the 3 bottom functions but its compiling. Where am I going wrong? import java.util.*; public class Main { public static void main(String[] args) { PriorityQueue queue1 = new…
0
votes
2 answers

How can I Join customer records in SQL Server to show missing transaction types

I have two simple tables comprised of CustomerNumber, TransactionNumber and AddonCode in each. The first table contains only TransactionNumber of 1 [Orig_DD]. This represents us transferring a customer from one system to another. The second table…
Phteven
  • 139
  • 1
  • 13
0
votes
1 answer

How to obtain difference of sets like behaviour with OOP

I need a behaviour similar to the set-theory's difference operator \. I am trying to get something of a friend class behaviour since i have the following situation: public interface IRead { List GetInnerResource(); } …
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
0
votes
1 answer

Binary '=': no operator found which takes a left-hand operand of type 'const Thing'

I have read duplicates but really didn't help me. I am trying to reach next behaviour. Having a vector composed by pairs {Thing, set < Thing >} I want a final result of{Thing, newSetOfThing < Thing >} where that 'newSetOfThing' is the difference…
0
votes
1 answer

Using a function to create a new dataframe with unused elements

I have two vectors with three elements. There are twenty total combinations of taking all six elements and rearranging them into different sets of two vectors with three elements. I need to write R code that will do that. My current code sets…
0
votes
3 answers

How can I find the "set difference" of rows in two dataframes on a subset of columns in Pandas?

I have two dataframes, say df1 and df2, with the same column names. Example: df1 C1 | C2 | C3 | C4 A 1 2 AA B 1 3 A A 3 2 B df2 C1 | C2 | C3 | C4 A 1 3 E B 1 2 C Q 4 1 Z I would like to filter…
GoodDeeds
  • 7,956
  • 5
  • 34
  • 61
0
votes
1 answer

Finding discrepancy between two data sets when setdiff is not working

I have data for spot price and day-ahead price for hour 2 and hour 3. They are as below. They are from 2015-12-31 to 2011-01-01 all the way down. > head(da2) Date Price Hour 43802 2015-12-31 12.56 2 43778 2015-12-30 23.59 2 43754…
junmouse
  • 155
  • 1
  • 9
0
votes
3 answers

List substraction with indices

Let's say I have a List A like that: line value 0 Object0 1 Object1 2 Object2 3 Object3 4 Object4 5 Object5 Now, I've another List B containing [0,2,3] (only Integer) which basically contains the indices of objects I've already…
Jérôme B
  • 311
  • 5
  • 18
0
votes
1 answer

To find diff between 2 vectors

To find diff between 2 vectors - one of the answers mentioned was: x[is.na(match(x,y))] with x <- c(1,2,3,4); y <- c(2,3,4. Can someone please explain this answer in detail ?
snk
  • 31
  • 3
0
votes
1 answer

how may I remove elements in a string vector by elements in another string vector

setdiff(c("a","c"),c("a","b","c","d")) #character(0) This code is supposed to return a vector of c("b","d"), what's wrong with it?
Z. Zhang
  • 637
  • 4
  • 16