In [1]:
%load_ext sql

In [3]:
%sql sqlite:///coal.db
%sql select * from data limit 5


Done.
Out[3]:
state name orispl_code unitid op_date year op_hour op_time gload SO2_MASS NOX_MASS CO2_MASS heat_input county latitude longitude fuel_type fuel_type_2 fuel_actual
WA Centralia 3845 BW21 01-01-2001 2001 0 1.0 704.0 11493.6 2506.854 720.5 7022.0 Lewis 46.7559 -122.8578 Coal Coal
WA Centralia 3845 BW21 01-01-2001 2001 1 1.0 706.0 11774.7 2577.369 736.6 7179.3 Lewis 46.7559 -122.8578 Coal Coal
WA Centralia 3845 BW21 01-01-2001 2001 2 1.0 704.0 11156.9 2606.306 718.8 7006.2 Lewis 46.7559 -122.8578 Coal Coal
WA Centralia 3845 BW21 01-01-2001 2001 3 1.0 702.0 10990.0 2561.697 716.2 6980.1 Lewis 46.7559 -122.8578 Coal Coal
WA Centralia 3845 BW21 01-01-2001 2001 4 1.0 702.0 11027.6 2631.762 716.2 6980.8 Lewis 46.7559 -122.8578 Coal Coal

In [4]:
%%sql
select year, SUM(gload) / SUM(heat_input) from data group by year


Done.
Out[4]:
year SUM(gload) / SUM(heat_input)
2001 0.0967844392933
2002 0.0970142449358
2003 0.0974750778606
2004 0.0980198873775
2005 0.0974221629152
2006 0.0973391424666
2007 0.0979293816329
2008 0.0989752671046
2009 0.0996937770402
2010 0.100816147699
2011 0.100958484881
2012 0.100928247411
2013 0.100731203589
2014 0.100928862738
2015 0.0999578004664
2016 0.100112662079

In [ ]: