joelgrus / data-science-from-scratch

code for Data Science From Scratch book
MIT License
8.63k stars 4.5k forks source link

most_common_interests_with(user_id) from Python 3 Introductions file #47

Open snooze opened 6 years ago

snooze commented 6 years ago

I think that:

def most_common_interests_with(user_id): return Counter(interested_user_id for interest in interests_by_user_id["user_id"] for interested_user_id in user_ids_by_interest[interest] if interested_user_id != user_id)

Should be:

def most_common_interests_with(user_id): return Counter(interested_user_id for interest in interests_by_user_id[user_id] for interested_user_id in user_ids_by_interest[interest] if interested_user_id != user_id)

Quotes around user_id in third quoted line removed.

Neshmwaniki commented 4 years ago

Agree, the former assumes integers are subscriptable @snooze good catch!