In [ ]:
%sql select max(CAST(gload as float)) as global_max_generation, max(CAST(heat_input as float)) as global_max_heat_input, name, orispl_code, unitid from data group by name, unitid

In [ ]:
def max_generation(dbname, table = "data", output = None):
    import sqlite3
    import pandas
    con = sqlite3.connect(dbname)
    cur = con.cursor()
    if output is None:
        output = dbname + "_max.csv"
    table = pandas.read_sql('select max(CAST(gload as float)) as global_max_generation, \
    max(CAST(heat_input as float)) as global_max_heat_input, name, orispl_code, unitid \
    from ' + table + ' group by name, unitid')
    table.to_csv(output)