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
\begin{figure*}[!tb] | |
\centering | |
\footnotesize | |
\begin{tabular}{cccc} | |
% First row of triad census | |
\begin{tikzpicture} | |
[user/.style={circle,draw=black,fill=black!60,thick,text=white,inner sep=0pt,minimum size=.5cm}, | |
->,-stealth,line width = 2, black, | |
font=\boldmath] |
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
from bs4 import BeautifulSoup | |
import requests | |
# Get the data | |
raw = requests.get('http://www.baseball-reference.com/leagues/MLB/2016-standings.shtml').text | |
# Parse it | |
soup = BeautifulSoup(raw,'html.parser') | |
# Find the table |
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
Verifying that +bkeegan is my openname (Bitcoin username). https://onename.com/bkeegan |
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
import numpy as np | |
import pandas as pd | |
from bs4 import BeautifulSoup, element | |
import urllib2, re | |
# Read the HTML from the webpage on Wikipedia stats and convert to soup | |
soup = BeautifulSoup(urllib2.urlopen('http://stats.wikimedia.org/EN/TablesWikipediaEN.htm').read()) | |
# Look for all the paragraphs with 2014 | |
_p = soup.findAll('b',text=re.compile('2014')) |
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
# adapted from http://matplotlib.org/examples/api/barchart_demo.html | |
def autolabel(rects): | |
max_height = max([rect.get_height() for rect in rects if hasattr(rect,'get_height') and not np.isnan(rect.get_height())]) | |
for rect in rects: | |
if hasattr(rect,'get_height'): | |
height = rect.get_height() | |
if not np.isnan(height): | |
ax.text(rect.get_x()+rect.get_width()/2., height-.1*max_height, '%d'%int(height), | |
ha='center', va='bottom',color='w') |
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
import pandas as pd | |
import numpy as np | |
import datetime | |
dft = pd.DataFrame({'A' : ['spam', 'eggs', 'spam', 'eggs'] * 6, | |
'B' : ['alpha', 'beta', 'gamma'] * 8, | |
'C' : [np.random.choice(pd.date_range(datetime.datetime(2013,1,1),datetime.datetime(2013,1,3))) for i in range(24)], | |
'D' : np.random.randn(24), | |
'E' : np.random.random_integers(0,4,24)}) |
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
# Serrano, Boguna, Vespigani backbone extractor | |
# from http://www.pnas.org/content/106/16/6483.abstract | |
# Thanks to Michael Conover and Qian Zhang at Indiana with help on earlier versions | |
# Thanks to Clay Davis for pointing out an error | |
import networkx as nx | |
import numpy as np | |
def extract_backbone(g, weight='weight', alpha=.05): | |
backbone_graph = nx.Graph() |