2

I have a dataframe and want to compare multiple columns of different rows and count the number of cases where both conditions are fullfilled.

Since my actual dataframe is pretty large, here's an example to simplify what I want to do:

Example

In the linked picture, you can see the simplified example. I want to count all cases where the age of Person A and B is the same and the current job of Person A is the same as the past job of Person B. This should return count=1 since Thomas and Ryan have the same age and Ryan's current job is the same as Thomas' previous job.

I hope my question is understandable and this is possible

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
0009
  • 49
  • 5
  • 2
    Please [provide a reproducible copy of the DataFrame with `to_clipboard`](https://stackoverflow.com/questions/52413246/provide-a-reproducible-copy-of-the-dataframe-with-to-clipboard/52413247#52413247). [Stack Overflow Discourages Screenshots](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). It is likely the question will be downvoted. You are discouraging assistance because no one wants to retype your data or code, and screenshots are often illegible. – Trenton McKinney Apr 22 '20 at 16:59
  • How do you define who is person A and person B?, or does it have to a comparison beteween everybody aginst everybody? – jcaliz Apr 22 '20 at 17:42

0 Answers0