Skip to content

Instantly share code, notes, and snippets.

@jboynyc
Created April 13, 2018 09:07
Show Gist options
  • Save jboynyc/08f314ad432df317086bb7dcbc843f31 to your computer and use it in GitHub Desktop.
Save jboynyc/08f314ad432df317086bb7dcbc843f31 to your computer and use it in GitHub Desktop.
Networks of Trump Town
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Populating the interactive namespace from numpy and matplotlib\n"
]
}
],
"source": [
"%pylab inline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true,
"scrolled": true
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import igraph as ig\n",
"import louvain"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def largest_component(graph):\n",
" '''Returns the largest connected component in a graph.'''\n",
" components = graph.components()\n",
" largest_component_size = max(components.sizes())\n",
" largest_component_index = components.sizes().index(largest_component_size)\n",
" return graph.subgraph(components[largest_component_index]) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The data come from ProPublica's [Trump Town](https://projects.propublica.org/trump-town/) project. As they point out, the data you use may contain errors and omissions."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"staff = pd.read_csv('data-store/staffers.csv', encoding='utf-8', escapechar='\\\\')\n",
"orgs = pd.read_csv('data-store/organizations.csv', encoding='utf-8', escapechar='\\\\')\n",
"roles = pd.read_csv('data-store/organization_roles.csv', encoding='utf-8', escapechar='\\\\')"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"staff_roles = pd.merge(staff, roles, right_on='staffer_id', left_on='id', how='left')\n",
"staff_orgs = pd.merge(staff_roles, orgs, left_on='organization_id', right_on='id')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"outside_positions = staff_orgs[staff_orgs['role'] == 'outside_government_position']"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"matrix = pd.pivot_table(outside_positions[['name_x', 'name_y', 'id_x']], \n",
" index='name_x', \n",
" columns=['name_y'], \n",
" aggfunc='count',\n",
" fill_value=0)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"staff_matrix = matrix.dot(matrix.T)\n",
"org_matrix = matrix.T.dot(matrix)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"staff_graph = ig.Graph.Weighted_Adjacency(np.array(staff_matrix).tolist(),\n",
" mode='undirected',\n",
" loops=False)\n",
"staff_graph.vs['label'] = list(staff_matrix.index)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"org_graph = ig.Graph.Weighted_Adjacency(np.array(org_matrix).tolist(),\n",
" mode='undirected',\n",
" loops=False)\n",
"org_graph.vs['label'] = [i[1] for i in org_matrix.index]"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>degree</th>\n",
" <th>org</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>3426</th>\n",
" <td>606.0</td>\n",
" <td>Trump for America, Inc.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3354</th>\n",
" <td>599.0</td>\n",
" <td>The Trump Organization, Inc.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3386</th>\n",
" <td>530.0</td>\n",
" <td>Times Square Associates, LLC</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3334</th>\n",
" <td>347.0</td>\n",
" <td>The Partnership for New York City</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3019</th>\n",
" <td>296.0</td>\n",
" <td>THC SALES &amp; MARKETING LLC (management company)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3029</th>\n",
" <td>296.0</td>\n",
" <td>THE TRUMP CORPORATION (management company)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3028</th>\n",
" <td>296.0</td>\n",
" <td>THC VENTURE II MANAGING MEMBER CORP. (pass-thr...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3027</th>\n",
" <td>296.0</td>\n",
" <td>THC VENTURE II LLC (dormant/inactive)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3026</th>\n",
" <td>296.0</td>\n",
" <td>THC VANCOUVER PAYROLL ULC (payroll company)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3025</th>\n",
" <td>296.0</td>\n",
" <td>THC VANCOUVER MANAGEMENT CORP (management comp...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3024</th>\n",
" <td>296.0</td>\n",
" <td>THC SHENZHEN HOTEL MANAGER MEMBER CORP (pass-t...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3023</th>\n",
" <td>296.0</td>\n",
" <td>THC SHENZHEN HOTEL MANAGER LLC (dormant/inactive)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3022</th>\n",
" <td>296.0</td>\n",
" <td>THC SERVICES SHENZHEN MEMBER CORP (pass-thru c...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3021</th>\n",
" <td>296.0</td>\n",
" <td>THC SERVICES SHENZHEN LLC (dormant/inactive)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3020</th>\n",
" <td>296.0</td>\n",
" <td>THC SALES &amp; MARKETING MEMBER CORP (pass-thru c...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3018</th>\n",
" <td>296.0</td>\n",
" <td>THC RIO MANAGING MEMBER CORP (pass- thru compa...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3031</th>\n",
" <td>296.0</td>\n",
" <td>THE TRUMP MARKS REAL ESTATE CORP (pass-thru co...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3017</th>\n",
" <td>296.0</td>\n",
" <td>THC RIO MANAGER LLC (dormant/inactive)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3016</th>\n",
" <td>296.0</td>\n",
" <td>THC QATAR HOTEL MANAGER MEMBER CORP (pass-thru...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3015</th>\n",
" <td>296.0</td>\n",
" <td>THC QATAR HOTEL MANAGER LLC (dormant/inactive)</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" degree org\n",
"3426 606.0 Trump for America, Inc.\n",
"3354 599.0 The Trump Organization, Inc.\n",
"3386 530.0 Times Square Associates, LLC\n",
"3334 347.0 The Partnership for New York City\n",
"3019 296.0 THC SALES & MARKETING LLC (management company)\n",
"3029 296.0 THE TRUMP CORPORATION (management company)\n",
"3028 296.0 THC VENTURE II MANAGING MEMBER CORP. (pass-thr...\n",
"3027 296.0 THC VENTURE II LLC (dormant/inactive)\n",
"3026 296.0 THC VANCOUVER PAYROLL ULC (payroll company)\n",
"3025 296.0 THC VANCOUVER MANAGEMENT CORP (management comp...\n",
"3024 296.0 THC SHENZHEN HOTEL MANAGER MEMBER CORP (pass-t...\n",
"3023 296.0 THC SHENZHEN HOTEL MANAGER LLC (dormant/inactive)\n",
"3022 296.0 THC SERVICES SHENZHEN MEMBER CORP (pass-thru c...\n",
"3021 296.0 THC SERVICES SHENZHEN LLC (dormant/inactive)\n",
"3020 296.0 THC SALES & MARKETING MEMBER CORP (pass-thru c...\n",
"3018 296.0 THC RIO MANAGING MEMBER CORP (pass- thru compa...\n",
"3031 296.0 THE TRUMP MARKS REAL ESTATE CORP (pass-thru co...\n",
"3017 296.0 THC RIO MANAGER LLC (dormant/inactive)\n",
"3016 296.0 THC QATAR HOTEL MANAGER MEMBER CORP (pass-thru...\n",
"3015 296.0 THC QATAR HOTEL MANAGER LLC (dormant/inactive)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.DataFrame({'org': org_graph.vs['label'],\n",
" 'degree': org_graph.strength(weights='weight')})\\\n",
" .sort_values('degree', ascending=False)\\\n",
" .head(20)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"connected_orgs = largest_component(org_graph)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"org_clusters = louvain.find_partition(connected_orgs, \n",
" weights='weight',\n",
" partition_type=louvain.ModularityVertexPartition)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[496, 297, 265, 166, 147, 139, 96, 96, 88, 81, 50, 33, 25, 22, 13, 4]"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"org_clusters.sizes()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>cluster_number</th>\n",
" <th>degree</th>\n",
" <th>org</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>446</th>\n",
" <td>0</td>\n",
" <td>308.0</td>\n",
" <td>Trump for America, Inc.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>150</th>\n",
" <td>0</td>\n",
" <td>230.0</td>\n",
" <td>Donald J. Trump for President, Inc.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>0</td>\n",
" <td>115.0</td>\n",
" <td>58th Presidential Inaugural Committee</td>\n",
" </tr>\n",
" <tr>\n",
" <th>116</th>\n",
" <td>0</td>\n",
" <td>50.0</td>\n",
" <td>Charter Venture Partners GP Inc</td>\n",
" </tr>\n",
" <tr>\n",
" <th>108</th>\n",
" <td>0</td>\n",
" <td>50.0</td>\n",
" <td>Charter Hoyle GP, INc</td>\n",
" </tr>\n",
" <tr>\n",
" <th>105</th>\n",
" <td>0</td>\n",
" <td>50.0</td>\n",
" <td>Charter Hampton GP Inc</td>\n",
" </tr>\n",
" <tr>\n",
" <th>106</th>\n",
" <td>0</td>\n",
" <td>50.0</td>\n",
" <td>Charter Hampton LP</td>\n",
" </tr>\n",
" <tr>\n",
" <th>48</th>\n",
" <td>0</td>\n",
" <td>50.0</td>\n",
" <td>Baylor Health Care System Foundation</td>\n",
" </tr>\n",
" <tr>\n",
" <th>107</th>\n",
" <td>0</td>\n",
" <td>50.0</td>\n",
" <td>Charter Holdings Inc</td>\n",
" </tr>\n",
" <tr>\n",
" <th>109</th>\n",
" <td>0</td>\n",
" <td>50.0</td>\n",
" <td>Charter Hoyle LP</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" cluster_number degree org\n",
"446 0 308.0 Trump for America, Inc.\n",
"150 0 230.0 Donald J. Trump for President, Inc.\n",
"5 0 115.0 58th Presidential Inaugural Committee\n",
"116 0 50.0 Charter Venture Partners GP Inc\n",
"108 0 50.0 Charter Hoyle GP, INc\n",
"105 0 50.0 Charter Hampton GP Inc\n",
"106 0 50.0 Charter Hampton LP\n",
"48 0 50.0 Baylor Health Care System Foundation\n",
"107 0 50.0 Charter Holdings Inc\n",
"109 0 50.0 Charter Hoyle LP"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>cluster_number</th>\n",
" <th>degree</th>\n",
" <th>org</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>289</th>\n",
" <td>1</td>\n",
" <td>591.0</td>\n",
" <td>The Trump Organization, Inc.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>296.0</td>\n",
" <td>40 WALL STREET COMMERCIAL LLC (payroll company)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>194</th>\n",
" <td>1</td>\n",
" <td>296.0</td>\n",
" <td>TRUMP INTERNATIONAL DEVELOPMENT MEMBER CORP (p...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>201</th>\n",
" <td>1</td>\n",
" <td>296.0</td>\n",
" <td>TRUMP MARKS ASIA LLC (residential real estate ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>200</th>\n",
" <td>1</td>\n",
" <td>296.0</td>\n",
" <td>TRUMP MARKS ASIA CORP (pass-thru company for T...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>199</th>\n",
" <td>1</td>\n",
" <td>296.0</td>\n",
" <td>TRUMP MARKETING LLC (license deal)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>198</th>\n",
" <td>1</td>\n",
" <td>296.0</td>\n",
" <td>TRUMP LAS VEGAS DEVELOPMENT LLC (entity set up...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>197</th>\n",
" <td>1</td>\n",
" <td>296.0</td>\n",
" <td>TRUMP LAS VEGAS CORP (pass-thru company for TR...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>196</th>\n",
" <td>1</td>\n",
" <td>296.0</td>\n",
" <td>TRUMP INTERNATIONAL HOTELS MANAGEMENT LLC (man...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>195</th>\n",
" <td>1</td>\n",
" <td>296.0</td>\n",
" <td>TRUMP INTERNATIONAL HOTEL HAWAII LLC (license ...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" cluster_number degree org\n",
"289 1 591.0 The Trump Organization, Inc.\n",
"0 1 296.0 40 WALL STREET COMMERCIAL LLC (payroll company)\n",
"194 1 296.0 TRUMP INTERNATIONAL DEVELOPMENT MEMBER CORP (p...\n",
"201 1 296.0 TRUMP MARKS ASIA LLC (residential real estate ...\n",
"200 1 296.0 TRUMP MARKS ASIA CORP (pass-thru company for T...\n",
"199 1 296.0 TRUMP MARKETING LLC (license deal)\n",
"198 1 296.0 TRUMP LAS VEGAS DEVELOPMENT LLC (entity set up...\n",
"197 1 296.0 TRUMP LAS VEGAS CORP (pass-thru company for TR...\n",
"196 1 296.0 TRUMP INTERNATIONAL HOTELS MANAGEMENT LLC (man...\n",
"195 1 296.0 TRUMP INTERNATIONAL HOTEL HAWAII LLC (license ..."
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>cluster_number</th>\n",
" <th>degree</th>\n",
" <th>org</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>223</th>\n",
" <td>2</td>\n",
" <td>528.0</td>\n",
" <td>Times Square Associates, LLC</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2</td>\n",
" <td>265.0</td>\n",
" <td>100 Pierrepoint Street LLC</td>\n",
" </tr>\n",
" <tr>\n",
" <th>181</th>\n",
" <td>2</td>\n",
" <td>265.0</td>\n",
" <td>New Puck Residential Corp.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>168</th>\n",
" <td>2</td>\n",
" <td>265.0</td>\n",
" <td>Livingston Hills Building Corp.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>169</th>\n",
" <td>2</td>\n",
" <td>265.0</td>\n",
" <td>Maryland Apartment Holdings 10-Pack JV, LLC</td>\n",
" </tr>\n",
" <tr>\n",
" <th>170</th>\n",
" <td>2</td>\n",
" <td>265.0</td>\n",
" <td>Megalith Capital Management</td>\n",
" </tr>\n",
" <tr>\n",
" <th>171</th>\n",
" <td>2</td>\n",
" <td>265.0</td>\n",
" <td>Middle River JV LLC</td>\n",
" </tr>\n",
" <tr>\n",
" <th>172</th>\n",
" <td>2</td>\n",
" <td>265.0</td>\n",
" <td>Milford Building Corp.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>173</th>\n",
" <td>2</td>\n",
" <td>265.0</td>\n",
" <td>Miracle Manor Property Owner LLC</td>\n",
" </tr>\n",
" <tr>\n",
" <th>174</th>\n",
" <td>2</td>\n",
" <td>265.0</td>\n",
" <td>Monmouth Mall 2, LLC</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" cluster_number degree org\n",
"223 2 528.0 Times Square Associates, LLC\n",
"0 2 265.0 100 Pierrepoint Street LLC\n",
"181 2 265.0 New Puck Residential Corp.\n",
"168 2 265.0 Livingston Hills Building Corp.\n",
"169 2 265.0 Maryland Apartment Holdings 10-Pack JV, LLC\n",
"170 2 265.0 Megalith Capital Management\n",
"171 2 265.0 Middle River JV LLC\n",
"172 2 265.0 Milford Building Corp.\n",
"173 2 265.0 Miracle Manor Property Owner LLC\n",
"174 2 265.0 Monmouth Mall 2, LLC"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>cluster_number</th>\n",
" <th>degree</th>\n",
" <th>org</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>3</td>\n",
" <td>96.0</td>\n",
" <td>American Enterprise Institute</td>\n",
" </tr>\n",
" <tr>\n",
" <th>42</th>\n",
" <td>3</td>\n",
" <td>81.0</td>\n",
" <td>Dick and Betsy DeVos Family Foundation</td>\n",
" </tr>\n",
" <tr>\n",
" <th>142</th>\n",
" <td>3</td>\n",
" <td>56.0</td>\n",
" <td>The Stow Company - Holland, Inc.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>67</th>\n",
" <td>3</td>\n",
" <td>56.0</td>\n",
" <td>Great Lakes Education Foundation</td>\n",
" </tr>\n",
" <tr>\n",
" <th>162</th>\n",
" <td>3</td>\n",
" <td>56.0</td>\n",
" <td>Windquest Group</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>3</td>\n",
" <td>56.0</td>\n",
" <td>BDV, Inc.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>60</th>\n",
" <td>3</td>\n",
" <td>56.0</td>\n",
" <td>GLEP Education Fund</td>\n",
" </tr>\n",
" <tr>\n",
" <th>48</th>\n",
" <td>3</td>\n",
" <td>43.0</td>\n",
" <td>Family Trust 12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>131</th>\n",
" <td>3</td>\n",
" <td>39.0</td>\n",
" <td>The Goldman Sachs Group, Inc.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>55</th>\n",
" <td>3</td>\n",
" <td>37.0</td>\n",
" <td>Forbes Media LLC</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" cluster_number degree org\n",
"11 3 96.0 American Enterprise Institute\n",
"42 3 81.0 Dick and Betsy DeVos Family Foundation\n",
"142 3 56.0 The Stow Company - Holland, Inc.\n",
"67 3 56.0 Great Lakes Education Foundation\n",
"162 3 56.0 Windquest Group\n",
"23 3 56.0 BDV, Inc.\n",
"60 3 56.0 GLEP Education Fund\n",
"48 3 43.0 Family Trust 12\n",
"131 3 39.0 The Goldman Sachs Group, Inc.\n",
"55 3 37.0 Forbes Media LLC"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>cluster_number</th>\n",
" <th>degree</th>\n",
" <th>org</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>4</td>\n",
" <td>64.0</td>\n",
" <td>AccuWeather Inc.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>41</th>\n",
" <td>4</td>\n",
" <td>50.0</td>\n",
" <td>Family Trust</td>\n",
" </tr>\n",
" <tr>\n",
" <th>125</th>\n",
" <td>4</td>\n",
" <td>42.0</td>\n",
" <td>The Heritage Foundation</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>4</td>\n",
" <td>36.0</td>\n",
" <td>American Bar Association</td>\n",
" </tr>\n",
" <tr>\n",
" <th>90</th>\n",
" <td>4</td>\n",
" <td>26.0</td>\n",
" <td>Melaleuca, Inc.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>131</th>\n",
" <td>4</td>\n",
" <td>25.0</td>\n",
" <td>U.S. Chamber of Commerce</td>\n",
" </tr>\n",
" <tr>\n",
" <th>142</th>\n",
" <td>4</td>\n",
" <td>19.0</td>\n",
" <td>Wells Fargo &amp; Company</td>\n",
" </tr>\n",
" <tr>\n",
" <th>93</th>\n",
" <td>4</td>\n",
" <td>15.0</td>\n",
" <td>Mirror Management One, LLC</td>\n",
" </tr>\n",
" <tr>\n",
" <th>76</th>\n",
" <td>4</td>\n",
" <td>15.0</td>\n",
" <td>MWX Services, Inc.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>4</td>\n",
" <td>15.0</td>\n",
" <td>American Weather and Climate Industry Association</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" cluster_number degree org\n",
"4 4 64.0 AccuWeather Inc.\n",
"41 4 50.0 Family Trust\n",
"125 4 42.0 The Heritage Foundation\n",
"9 4 36.0 American Bar Association\n",
"90 4 26.0 Melaleuca, Inc.\n",
"131 4 25.0 U.S. Chamber of Commerce\n",
"142 4 19.0 Wells Fargo & Company\n",
"93 4 15.0 Mirror Management One, LLC\n",
"76 4 15.0 MWX Services, Inc.\n",
"12 4 15.0 American Weather and Climate Industry Association"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>cluster_number</th>\n",
" <th>degree</th>\n",
" <th>org</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>5</td>\n",
" <td>39.0</td>\n",
" <td>Columbia University</td>\n",
" </tr>\n",
" <tr>\n",
" <th>129</th>\n",
" <td>5</td>\n",
" <td>27.0</td>\n",
" <td>University of Texas</td>\n",
" </tr>\n",
" <tr>\n",
" <th>91</th>\n",
" <td>5</td>\n",
" <td>22.0</td>\n",
" <td>Revocable Family Trust #1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>5</td>\n",
" <td>22.0</td>\n",
" <td>Center for a New American Security</td>\n",
" </tr>\n",
" <tr>\n",
" <th>41</th>\n",
" <td>5</td>\n",
" <td>19.0</td>\n",
" <td>Georgetown University</td>\n",
" </tr>\n",
" <tr>\n",
" <th>48</th>\n",
" <td>5</td>\n",
" <td>18.0</td>\n",
" <td>Hoover Institution</td>\n",
" </tr>\n",
" <tr>\n",
" <th>130</th>\n",
" <td>5</td>\n",
" <td>16.0</td>\n",
" <td>University of Virginia</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>5</td>\n",
" <td>13.0</td>\n",
" <td>Booze Allen Hamilton</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>5</td>\n",
" <td>12.0</td>\n",
" <td>CENTRA Technology, Inc.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>5</td>\n",
" <td>12.0</td>\n",
" <td>Document Security Systems, Inc.</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" cluster_number degree org\n",
"22 5 39.0 Columbia University\n",
"129 5 27.0 University of Texas\n",
"91 5 22.0 Revocable Family Trust #1\n",
"20 5 22.0 Center for a New American Security\n",
"41 5 19.0 Georgetown University\n",
"48 5 18.0 Hoover Institution\n",
"130 5 16.0 University of Virginia\n",
"14 5 13.0 Booze Allen Hamilton\n",
"16 5 12.0 CENTRA Technology, Inc.\n",
"28 5 12.0 Document Security Systems, Inc."
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"for num, cluster in enumerate(org_clusters):\n",
" if len(cluster) >= 100:\n",
" sub = connected_orgs.subgraph(cluster)\n",
" display(pd.DataFrame({'org': sub.vs['label'], \n",
" 'degree': sub.strength(weights='weight'),\n",
" 'cluster_number': num}).sort_values('degree', ascending=False).head(10))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment