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
""" | |
tiny script to convert a pandas data frame into a JSON object | |
""" | |
import json as json | |
def df_to_json(df, filename=''): | |
x = df.reset_index().T.to_dict().values() | |
if filename: | |
with open(filename, 'w+') as f: f.write(json.dumps(x)) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
State | Growth | 2008 | 2009 | 2010 | 2011 | |
---|---|---|---|---|---|---|
UT | 26% | 15366.84 | 10640.13 | 14512.30 | 19384.97 | |
DE | 38% | 26968.08 | 19269.31 | 24448.17 | 37208.37 | |
RI | 14% | 24220.50 | 17278.61 | 22368.74 | 27630.56 | |
GA | 30% | 18642.63 | 13752.71 | 17506.62 | 24232.52 | |
AZ | 36% | 13217.43 | 8984.05 | 12118.08 | 17951.43 | |
AR | 21% | 13600.70 | 11097.47 | 12670.71 | 16436.84 | |
AL | 14% | 14941.88 | 11072.41 | 13428.64 | 17072.95 | |
AK | 3% | 16175.87 | 12507.99 | 16233.93 | 16622.15 | |
OR | 37% | 23216.79 | 17183.07 | 20924.93 | 31754.11 |
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
[ | |
{ | |
"color": "#1f77b4", | |
"key": "2011-01-01", | |
"values": [ | |
[ | |
1210291200, | |
0.0004590374261905092 | |
], | |
[ |
We can't make this file beautiful and searchable because it's too large.
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
SEQGEN09,PSTATABB,PNAME,ORISPL,GENID,NUMBLR,GENSTAT,PRMVR,FUELG1,NAMEPCAP,CFACT,GENNTAN,GENNTOZ,GENERSRC,GENYRONL | |
1.0,AK,Alakanuk,57053,UNIT1,0.0,OP,IC,JF,0.40000000000000002,0.0,0.0,0.0,,2008.0 | |
2.0,AK,Alakanuk,57053,UNIT2,0.0,OP,IC,JF,0.5,0.0,0.0,0.0,,1999.0 | |
3.0,AK,Alakanuk,57053,UNIT3,0.0,OP,IC,JF,0.40000000000000002,0.0,0.0,0.0,,1993.0 | |
4.0,AK,Anchorage 1,75,D1,0.0,OP,IC,DFO,1.1000000000000001,0.0,0.0,0.0,,1956.0 | |
5.0,AK,Anchorage 1,75,D2,0.0,OP,IC,DFO,1.1000000000000001,0.0,0.0,0.0,,1947.0 | |
6.0,AK,Anchorage 1,75,1,0.0,OP,GT,NG,12.5,0.0,0.0,0.0,,1962.0 | |
7.0,AK,Anchorage 1,75,2,0.0,OP,GT,NG,12.5,0.0,0.0,0.0,,1962.0 | |
8.0,AK,Anchorage 1,75,3R,0.0,OP,GT,NG,48.899999999999999,0.0,0.0,0.0,,2007.0 | |
9.0,AK,Anchorage 1,75,4,0.0,OP,GT,NG,27.0,0.0,0.0,0.0,,1972.0 |
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 objgraph | |
class BaseClass(object): | |
def some_method(args): print args | |
class DerivedClass(BaseClass): | |
def __init__(self, *args): | |
print 'new derived class' | |
self.args = args | |
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
[{"values": [{"y": 0, "x": "January"}, {"y": 0, "x": "February"}, {"y": 0, "x": "March"}, {"y": 0, "x": "April"}, {"y": 6, "x": "May"}, {"y": 5, "x": "June"}, {"y": 7, "x": "July"}, {"y": 5, "x": "August"}, {"y": 2, "x": "September"}, {"y": 4, "x": "October"}, {"y": 2, "x": "November"}, {"y": 7, "x": "December"}], "key": "2007"}, {"values": [{"y": 2, "x": "January"}, {"y": 3, "x": "February"}, {"y": 9, "x": "March"}, {"y": 5, "x": "April"}, {"y": 7, "x": "May"}, {"y": 11, "x": "June"}, {"y": 10, "x": "July"}, {"y": 3, "x": "August"}, {"y": 4, "x": "September"}, {"y": 3, "x": "October"}, {"y": 8, "x": "November"}, {"y": 1, "x": "December"}], "key": "2008"}, {"values": [{"y": 3, "x": "January"}, {"y": 3, "x": "February"}, {"y": 7, "x": "March"}, {"y": 5, "x": "April"}, {"y": 1, "x": "May"}, {"y": 1, "x": "June"}, {"y": 6, "x": "July"}, {"y": 8, "x": "August"}, {"y": 6, "x": "September"}, {"y": 2, "x": "October"}, {"y": 3, "x": "November"}, {"y": 8, "x": "December"}], "key": "2009"}, {"values": [{"y": 4, "x": "J |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.4.6"></script> | |
</head> | |
<body> | |
<ul id="list"> | |
<li data-username="shawnbot">Shawn Allen</li> | |
<li data-username="mbostock">Mike Bostock</li> | |
</ul> |
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 coopr import pyomo | |
model =pyomo.ConcreteModel() | |
times=[1,2,3,4,5] | |
model.t =pyomo.Set(initialize=times) | |
model.x =pyomo.Var(model.t, bounds=(0,3)) | |
model.y =pyomo.Var(model.t, bounds=(0,300)) | |
x_discrete=[0,0.5,1,1.5,2,2.5,3] | |
xD=dict((t,x_discrete) for t in times) |