data-science-from-scratch
data-science-from-scratch copied to clipboard
code to sort people from the most friends to the least friends is missing in introduction.py
code to sort people from the most friends to the least friends is missing in introduction.py .
Oops!
I think there must be something you mistake when you write the final draft into the PDF for publishing.
The code in PDF book Page 3 shows that id is form 0 to 9.
But in code result shown in Page 5 is 1 to 10.
I believe you want to user 0 to 9 for code in page 7 clearly shows that.
interests list is form 0 to 9.
I have coded these codes following your book
num_friends_by_id = [(user["id"],number_of_friends(user))
for user in users]
sorted(num_friends_by_id,
key=lambda (users_id , num_friends): num_friends,
reverse=True)