-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editing group dict and writing main function to retrieve data #45
Open
sophmrtn
wants to merge
5
commits into
UCL-RITS:main
Choose a base branch
from
ArielLauu:sdm03
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
This code contains functions allowing for saving and loading from a yaml file. Answers to UCL-RITS/rse-classwork-2020#11 |
stefpiatek
reviewed
Oct 29, 2020
Comment on lines
+30
to
+47
data = group_dict.values() | ||
|
||
# 1. Calculate maximum age in the group | ||
maximum_age = max([x['age'] for x in data]) | ||
print('The maximum age in group_dict is :', maximum_age) | ||
|
||
# 2. Average number of relations in the group | ||
import numpy as np | ||
av_connections = np.mean([len(x['connection']) for x in data]) | ||
print('The average number of connections in group_dict is :', av_connections) | ||
|
||
#3. The maximum age of people with at least one relation | ||
maximum_age = max([x['age'] for x in data if len(x['connection']) >= 1]) | ||
print('The maximum age of people in group_dict with at least one connection is :', maximum_age) | ||
|
||
#4. The maximum age of people in the group that have at least one friend | ||
maximum_age = max([x['age'] for x in data if len([connection for connection in x['connection'].values() if connection=='friend']) >=1 ]) | ||
print('The maximum age of people in group_dict with at least one friend is :', maximum_age) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit contains code to print answers based on data comprehension e.g. maximum age, conditionality statements and looping through data.
Answering to issue UCL-RITS/rse-classwork-2020#10