from pyeconlab.trade.util import describe print "Running RAW_SIMPLESTATS_TABLE ..." DIR = RESULTS_DIR + "tables/" STORE = SOURCE_DIR + STORE print "Running STATS on File %s" % STORE store = pd.HDFStore(STORE) for dataset in sorted(store.keys()): dataset = dataset.strip("/") #Remove Directory Structure print "Computing SIMPLE STATS for dataset: %s" % dataset data = pd.read_hdf(STORE, key=dataset) productcode = "hs6" dataset_table = describe(data, table_name=dataset, productcode=productcode, exporter="eiso3n", importer="iiso3n") del data gc.collect() store.close() #-Excel Table-# fl = "baciraw-trade-hs6-1998to2012_stats.xlsx" dataset_table.to_excel(DIR + fl) #-Latex Snippet-# fl = "baciraw-trade-hs6-1998to2012_stats.tex" with open(DIR + fl, "w") as latex_file: latex_file.write(dataset_table.to_latex()) #----------# #-DATASETS-# #----------#
print "Running RAW_SIMPLESTATS_TABLE ..." DIR = RESULTS_DIR + "tables/" STORE = SOURCE_DIR + STORE print "Running STATS on File %s" % STORE store = pd.HDFStore(STORE) for dataset in sorted(store.keys()): dataset = dataset.strip("/") #Remove Directory Structure print "Computing SIMPLE STATS for dataset: %s" % dataset data = pd.read_hdf(STORE, key=dataset) productcode = "hs6" dataset_table = describe(data, table_name=dataset, productcode=productcode, exporter="eiso3n", importer="iiso3n") del data gc.collect() store.close() #-Excel Table-# fl = "baciraw-trade-hs6-1998to2012_stats.xlsx" dataset_table.to_excel(DIR + fl) #-Latex Snippet-# fl = "baciraw-trade-hs6-1998to2012_stats.tex" with open(DIR + fl, "w") as latex_file: latex_file.write(dataset_table.to_latex()) #----------# #-DATASETS-#
from pyeconlab.trade.util import describe print "Running DATASET_SIMPLESTATS_TABLE: ..." DIR = RESULTS_DIR + "tables/" for dataset_file in STORES: print "Running STATS on File %s" % dataset_file store = pd.HDFStore(dataset_file) for dataset in sorted(store.keys()): dataset = dataset.strip("/") #Remove Directory Structure print "Computing SIMPLE STATS for dataset: %s" % dataset data = pd.read_hdf(dataset_file, key=dataset) productcode = "".join(dataset_file.split("/")[-1].split("-")[2].split("r2l")) dataset_table = describe(data, table_name=dataset, productcode=productcode) #-Memory Reduction-# del data gc.collect() if dataset == "A": table = dataset_table else: table = table.merge(dataset_table, left_index=True, right_index=True) store.close() #-Excel Table-# fl = dataset_file.split("/")[-1].split(".")[0] + "_stats" + ".xlsx" table.to_excel(DIR + fl) #-Latex Snippet-# fl = dataset_file.split("/")[-1].split(".")[0] + "_stats" + ".tex" with open(DIR + fl, "w") as latex_file: latex_file.write(table.to_latex())
iiso3n, eiso3n = nber.intertemporal_countrycodes_raw_data(verbose=True) iiso3n.to_excel(DIR + "raw_intertemporal_iiso3n.xlsx") eiso3n.to_excel(DIR + "raw_intertemporal_eiso3n.xlsx") #### ----> END COMPOSITION TABLES <---- #### #### ----> SIMPLE STATS TABLES <---- #### if RAW_SIMPLESTATS_TABLE: from pyeconlab.trade.util import describe print "Running RAW_SIMPLESTATS_TABLE ..." DIR = RESULTS + "tables/" nber = NBERWTFConstructor(source_dir=SOURCE_DATA_DIR) table = describe(nber.dataset, productcode="sitc4", importer="importer", exporter="exporter") #-Excel Table-# table.to_excel(DIR + "raw_wtf_stats.xlsx") #-Latex Snippet-# with open(DIR + "raw_wtf_stats_table.latex", "w") as latex_file: latex_file.write(table.to_latex()) del nber #-Change this to a Single Table-# # #-By Year-# # for year in xrange(1962,2000+1,1): # nber_year = NBERWTFConstructor(source_dir=SOURCE_DATA_DIR, years=[year]) # table = describe(nber_year.dataset, productcode="sitc4", importer="importer", exporter="exporter") # #-Excel Table-# # table.to_excel(DIR + "raw_wtf_stats_%s.xlsx" % year) # #-Latex Snippet-#