Skip to content

Instantly share code, notes, and snippets.

@tomasonjo
Created May 25, 2022 15:55
Show Gist options
  • Save tomasonjo/8190c2d92ad4a1570a780442f3ad1c93 to your computer and use it in GitHub Desktop.
Save tomasonjo/8190c2d92ad4a1570a780442f3ad1c93 to your computer and use it in GitHub Desktop.
# Get component sizes
graph_features = graph_features.merge(
graph_features.groupby('componentId').size().to_frame('componentSize').reset_index(), on="componentId")
# Define a feature which indicates if the component has more than 1 member
graph_features['part_of_community'] = (graph_features['componentSize'] > 1).astype(int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment