ComenzarEmpieza gratis

Betweenness centrality

Betweenness centrality for retweet and reply networks signals users who bridge between different Twitter communities. These communities may be tied together by topic or ideology.

networkx has been imported as nx. The networks G_rt and G_reply, and column_names = ['screen_name', 'betweenness_centrality'] have been loaded for you.

Este ejercicio forma parte del curso

Analyzing Social Media Data in Python

Ver curso

Instrucciones del ejercicio

  • Calculate betweenness centrality for the retweet network using nx.betweenness_centrality().
  • Do the same for the reply network.
  • Create a DataFrame out of retweet centralities.
  • Do the same for the reply network.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# Generate betweenness centrality for retweets 
rt_centrality = ____

# Generate betweenness centrality for replies 
reply_centrality = ____

# Store centralities in data frames
rt = pd.DataFrame(____, ____ = ____)
reply = pd.DataFrame(____, ____ = ____)

# Print first five results in descending order of centrality
print(rt.sort_values('betweenness_centrality', ascending = False).head())

# Print first five results in descending order of centrality
print(reply.sort_values('betweenness_centrality', ascending = False).head())
Editar y ejecutar código