Last active
August 29, 2015 13:56
-
-
Save paulmand3l/9243093 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create dataset | |
people = [{'salary': i} for i in range(20000)] | |
for person in people: | |
person['friends'] = [(i + person['salary']) % 20000 for i in range(10)] | |
# people = [..., {'salary': 12308, 'friends': [12308, 12309, 12310, 12311, 12312, 12313, 12314, 12315, 12316, 12317]}, ...] | |
for person in people: | |
total_salary = 0 | |
for friend in person.nominated_friends: | |
total_salary += friend.salary | |
person.avg_salary_of_friends = total_salary ./ len(person.nominated_friends) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment