pythonnumpypandas
Ben Gorman

Ben Gorman

Life's a garden. Dig it.

You polled five heterosexual couples on their hobbies.

import numpy as np
import pandas as pd
 
couples = pd.DataFrame({
    'man': [
        ['fishing', 'biking', 'reading'],
        ['hunting', 'mudding', 'fishing'],
        ['reading', 'movies', 'running'],
        ['running', 'reading', 'biking', 'mudding'],
        ['movies', 'reading', 'yodeling']
    ],
    'woman': [
        ['biking', 'reading', 'movies'],
        ['fishing', 'drinking'],
        ['knitting', 'reading'],
        ['running', 'biking', 'fishing', 'movies'],
        ['movies']
    ]
})
 
print(couples)
#                                    man                               woman
# 0           [fishing, biking, reading]           [biking, reading, movies]
# 1          [hunting, mudding, fishing]                 [fishing, drinking]
# 2           [reading, movies, running]                 [knitting, reading]
# 3  [running, reading, biking, mudding]  [running, biking, fishing, movies]
# 4          [movies, reading, yodeling]                            [movies]

For each couple, determine what hobbies each man has that his wife doesn't and what hobbies each woman has that her husband doesn't.


Solution

This content is gated

Subscribe to one of the products below to gain access