In [34]:
import sqlite3
import pandas
con = sqlite3.connect('2016.db')
table = pandas.read_sql("select avg(heat_input), avg(gload), op_hour from data where fuel_actual is 'NG' and state is 'CA' and substr(op_date, 1, 2) is '06' group by op_hour", con)
table.to_csv('ca_ng_june.csv')
In [ ]:
import sqlite3
import pandas
con = sqlite3.connect('2016.db')
table = pandas.read_sql("select substr(op_date, 1, 2) as month, name, orispl_code, unitid, avg(heat_input) as avg_heat, avg(gload) as avg_gen, op_hour from data where fuel_actual is 'NG' and state is 'CA' group by op_hour, substr(op_date, 1, 2), orispl_code, unitid ", con)
table.to_csv('ca_ng_june.csv')
In [11]:
import sqlite3
import pandas
con = sqlite3.connect('2016.db')
table = pandas.read_sql("select * from ( \
select avg(gload), op_hour from data where fuel_actual is 'NG' and state is 'CA' and substr(op_date, 1, 2) is '06' group by op_hour ) as a \
, data as ", con)
table.to_csv('ca_ng_june.csv')
In [12]:
%sql sqlite:///2016.db
Out[12]:
In [20]:
%sql select gload, heat_input, unitid, op_date, op_hour from data where name is 'Colstrip' and substr(op_date, 1, 2) is '06' order by unitid limit 5
Out[20]:
In [ ]: