Example #1
0
def check_covered_component():
    ids = gbs.get_covered_set()
    f_ids = [x for x in ids if '0000' in x]
    b_ids = [x for x in ids if not '0000' in x]
    euas = gbs.get_all_building_set()
    print len(euas)
    print 'total {0}, facility {1}, building {2}'.format(
        len(ids), len(f_ids), len(b_ids))
    for f in f_ids:
        dfs = []
        df = uo.view_building(f, 'Electric_(kBtu)')
        bs = [
            x for x in euas
            if '{0}0000{1}'.format(x[:2], x[-2:]) == f and not '0000' in x
        ]
        if len(bs) == 0:
            print 'no building under {0}'.format(f)
            continue
        dfs.append(df)
        for b in bs:
            df = uo.view_building(b, 'Electric_(kBtu)')
            dfs.append(df)
        df_all = pd.concat(dfs, ignore_index=True)
        df_all.sort(['year', 'month', 'Building_Number'], inplace=True)
        print 'write to {0}.csv'.format(f)
        df_all.to_csv(homedir + 'question/facility_building/{0}.csv'.format(f),
                      index=False)
Example #2
0
File: check.py Project: yujiex/GSA
def show_covered_exception(b, **kwargs):
    euas = gbs.get_all_building_set()
    print b in euas
    bs = [x for x in euas if '{0}0000{1}'.format(x[:2], x[-2:]) == b]
    if 'bs' in kwargs:
        bs = kwargs['bs']
    dfs = []
    df = uo.view_building(b, 'Electric_(kBtu)')
    dfs.append(df)
    if 'year' in kwargs:
        year = kwargs['year']
        df = df[(df['year'] == year) & (df['month'].isin([1, 2, 3]))]
        print b
        print df[['Region_No.', 'month', 'Electric_(kBtu)']]
    for x in bs[:3]:
        print x
        df = uo.view_building(x, 'Electric_(kBtu)')
        if 'year' in kwargs:
            year = kwargs['year']
            df = df[(df['year'] == year) & (df['month'].isin([1, 2, 3]))]
        dfs.append(df)
        if 'year' in kwargs:
            print
            print df[['Region_No.', 'month', 'Electric_(kBtu)']]
    df_all = pd.concat(dfs, ignore_index=True)
    df_all.drop(['year', 'month'], axis=1, inplace=True)
    df_all.sort(['Fiscal_Year', 'Fiscal_Month', 'Building_Number'],
                inplace=True)
    print 'write to {0}.csv'.format(b)
    df_all.to_csv(homedir + 'question/facility_building/{0}.csv'.format(b), index=False)
    return
Example #3
0
def show_covered_exception(b, **kwargs):
    euas = gbs.get_all_building_set()
    print b in euas
    bs = [x for x in euas if '{0}0000{1}'.format(x[:2], x[-2:]) == b]
    if 'bs' in kwargs:
        bs = kwargs['bs']
    dfs = []
    df = uo.view_building(b, 'Electric_(kBtu)')
    dfs.append(df)
    if 'year' in kwargs:
        year = kwargs['year']
        df = df[(df['year'] == year) & (df['month'].isin([1, 2, 3]))]
        print b
        print df[['Region_No.', 'month', 'Electric_(kBtu)']]
    for x in bs[:3]:
        print x
        df = uo.view_building(x, 'Electric_(kBtu)')
        if 'year' in kwargs:
            year = kwargs['year']
            df = df[(df['year'] == year) & (df['month'].isin([1, 2, 3]))]
        dfs.append(df)
        if 'year' in kwargs:
            print
            print df[['Region_No.', 'month', 'Electric_(kBtu)']]
    df_all = pd.concat(dfs, ignore_index=True)
    df_all.drop(['year', 'month'], axis=1, inplace=True)
    df_all.sort(['Fiscal_Year', 'Fiscal_Month', 'Building_Number'],
                inplace=True)
    print 'write to {0}.csv'.format(b)
    df_all.to_csv(homedir + 'question/facility_building/{0}.csv'.format(b),
                  index=False)
    return
Example #4
0
File: check.py Project: yujiex/GSA
def check_covered_component():
    ids = gbs.get_covered_set()
    f_ids = [x for x in ids if '0000' in x]
    b_ids = [x for x in ids if not '0000' in x]
    euas = gbs.get_all_building_set()
    print len(euas)
    print 'total {0}, facility {1}, building {2}'.format(len(ids), len(f_ids), len(b_ids))
    for f in f_ids:
        dfs = []
        df = uo.view_building(f, 'Electric_(kBtu)')
        bs = [x for x in euas if '{0}0000{1}'.format(x[:2], x[-2:]) == f and not '0000' in x]
        if len(bs) == 0:
            print 'no building under {0}'.format(f)
            continue
        dfs.append(df)
        for b in bs:
            df = uo.view_building(b, 'Electric_(kBtu)')
            dfs.append(df)
        df_all = pd.concat(dfs, ignore_index=True)
        df_all.sort(['year', 'month', 'Building_Number'], inplace=True)
        print 'write to {0}.csv'.format(f)
        df_all.to_csv(homedir + 'question/facility_building/{0}.csv'.format(f), index=False)