text_plain_output_1.png
import networkx as nx

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

about_data = pd.read_csv('../input/AboutIsis.csv', encoding='ISO-8859-1')
fanboy_data = pd.read_csv('../input/IsisFanboy.csv', encoding='ISO-8859-1')

about_data.keys()

fanboy_space_split = [str(i).split() for i in fanboy_data['tweets']]
fanboy_handles = [j for i in fanboy_space_split for j in i if '@' in j]
about_space_split = [str(i).split() for i in about_data['tweets']]
about_handles = [j for i in about_space_split for j in i if '@' in j]

fanboy_edges = [(k, j[1:]) for k, i in zip(fanboy_data['username'], fanboy_space_split) for j in i if '@' in j]
about_edges = [(k, j[1:]) for k, i in zip(about_data['username'], about_space_split) for j in i if '@' in j]

about_graph = nx.Graph()
fanboy_graph = nx.Graph()

about_graph.add_edges_from(about_edges)
fanboy_graph.add_edges_from(fanboy_edges)

print(1 / (float(fanboy_graph.order()) / float(fanboy_graph.size())))
print(1 / (float(about_graph.order()) / float(about_graph.size())))