コード例 #1
0
def latex_table(inner_tabular: str,
                position="H",
                caption=None,
                escape_caption=False,
                label=None,
                output_filepath=None):
    table = Table(position=position)
    table.append(NoEscape(inner_tabular))

    if caption:
        caption_ = caption if escape_caption else NoEscape(caption)
        table.add_caption(caption_)

    if label:
        table.append(NoEscape("\label{{tab:{label}}}".format(label=label)))

    if output_filepath:
        table.generate_tex(output_filepath)

    return table.dumps()
コード例 #2
0
                 data="HICP"), MultiColumn(2, align='|c', data="UNEM")))
tabr.add_hline(start=2, end=3, cmidruleoption="lr")
tabr.add_hline(start=4, end=5, cmidruleoption="lr")
tabr.add_hline(start=6, end=7, cmidruleoption="lr")
tabr.add_row([""] + ["1Y", "2Y"] + ["1Y", "2Y"] + ["1Y", "2Y"])
tabr.add_hline()
# fill in the rows of tabular
for i in range(9):
    tabr.add_row([ds_stats[i]] +
                 ["{:.2f}".format(item) for item in spf_desc_stat.iloc[i, :]])
# end of table
tabr.add_hline()
# add tabular to table
tabl.append(tabr)
# export the table
tabl.generate_tex(tab_path + "spf_Desc_Stats")

#########################################
# PLOT OF INDIVIDUAL FORECASTS VS TARGET#
#########################################

# SPF individual forecasts and the target
fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(14, 15))
# RGDP (1Y)
a = axes[0, 0]
col_cyc = cycler('color', ['red'] + ['dimgrey'] * spf_bal_RGDP_1Y.shape[1])
mar_cyc = cycler('marker', ['.'] + [''] * spf_bal_RGDP_1Y.shape[1])
a.set_prop_cycle(col_cyc + mar_cyc)
spf_bal_RGDP_1Y.plot(ax=a, linewidth=0.5)
a.set_title('Real GDP Growth (1 Year Horizon)')
a.set_xlabel('Time')
コード例 #3
0
        tabr.add_row(
            [""] + [spf_multitable.index[i]] +
            ["{:.2f}".format(item) for item in spf_multitable.iloc[i, :]])

    tabr.add_hline()
    for i in range(29, 32):
        tabr.add_row(
            [""] + [spf_multitable.index[i]] +
            ["{:.2f}".format(item) for item in spf_multitable.iloc[i, :]])

    # end of table
    tabr.add_hline()
    # add tabular to table
    tabl.append(tabr)
    # export the table
    tabl.generate_tex(tab_path + "spf_comb_perf_" + str(w))

# FORECAST COMBINATION FIGURES
comb_methods = [
    'ECB', 'Equal Weights', 'Bates-Granger (1)', 'Bates-Granger (2)',
    'Bates-Granger (3)', 'Bates-Granger (4)', 'Bates-Granger (5)',
    'Granger-Ramanathan (1)', 'Granger-Ramanathan (2)',
    'Granger-Ramanathan (3)', 'AFTER', 'Median Forecast',
    'Trimmed Mean Forecast', 'PEW', 'Principal Component Forecast',
    'Principal Component Forecast (AIC)', 'Principal Component Forecast (BIC)',
    'Empirical Bayes Estimator', 'Kappa-Shrinkage',
    'Two-Step Egalitarian LASSO', 'BMA (Marginal Likelihood)',
    'BMA (Predictive Likelihood)', 'ANN', 'EP-NN', 'Bagging',
    'Componentwise Boosting', 'AdaBoost', 'c-APM (Constant)',
    'c-APM (Q-learning)', 'Market for Kernels'
]
コード例 #4
0
def gen_tex_table(tbl, cap, file_name, r):
    """
    The function creates a tex file to which it export the given table from
    python.

    Parameters
    ----------
    tbl : DataFrame
        DataFrame containing the table to be exported.

    cap : Str
        Table caption.

    file_name : Str
        Name of the tex file in the "Tables" directory.


    r : Int
       Number of decimals to round up the metrics.
    """

    # create tabule object
    tabl = Table()
    tabl.add_caption(cap)
    tabl.append(NoEscape("\label{tab: " + cap + "}"))

    # create tabular object
    tabr = Tabular(table_spec="lccc")
    tabr.add_hline()
    tabr.add_hline()

    # header row
    tabr.add_row(["Forecast Combination Method"] + list(tbl))
    tabr.add_hline()

    # number of combination methods + additional rows
    R = tbl.shape[0]

    # specify format
    fmt = "{:." + str(r) + "f}"

    # fill in the rows for each combination method (-3 for individuals)
    for i in range(R-3):

        tabr.add_row([tbl.index[i]] + [
                fmt.format(item) for item in tbl.iloc[i, :]])

    tabr.add_hline()

    # additional rows
    for i in range(R-3, R):

        tabr.add_row([tbl.index[i]] + [
                fmt.format(item) for item in tbl.iloc[i, :]])

    # end of table
    tabr.add_hline()
    tabr.add_hline()

    # add tabular to table
    tabl.append(tabr)

    # export the table
    tabl.generate_tex("C:/Users/Marek/Dropbox/Master_Thesis/Latex/Tables/" +
                      file_name)

    return
コード例 #5
0
tabr.add_hline()
tabr.add_hline()
# header row
tabr.add_row(["Statistic"] + tickers)
tabr.add_hline()
# fill in the rows of tabular
for i in range(9):
    tabr.add_row([ds_stats[i]] +
                 ["{:.7f}".format(item) for item in ret_desc_stat.iloc[i, :]])
# end of table
tabr.add_hline()
tabr.add_hline()
# add tabular to table
tabl.append(tabr)
# export the table
tabl.generate_tex(tab_path + "bond_ret_desc_stats")

# REALIZED VOLATILITY
rvol_desc_stat = pd.DataFrame(data=np.full((9, 4), np.nan, dtype=np.float),
                              columns=tickers,
                              index=ds_stats)
rvol_desc_stat.iloc[0, :] = np.mean(rvol.values, axis=0)
rvol_desc_stat.iloc[1, :] = np.median(rvol.values, axis=0)
rvol_desc_stat.iloc[2, :] = stats.mode(rvol.values, axis=0)[0]
rvol_desc_stat.iloc[3, :] = np.std(rvol.values, axis=0)
rvol_desc_stat.iloc[4, :] = np.var(rvol.values, axis=0)
rvol_desc_stat.iloc[5, :] = np.min(rvol.values, axis=0)
rvol_desc_stat.iloc[6, :] = np.max(rvol.values, axis=0)
rvol_desc_stat.iloc[7, :] = stats.kurtosis(rvol.values, axis=0)
rvol_desc_stat.iloc[8, :] = stats.skew(rvol.values, axis=0)
コード例 #6
0
tabr.add_row(
    ("", MultiColumn(2, align='|c|', data="Pilot 1"),
     MultiColumn(2, align='|c|',
                 data="Pilot 2"), MultiColumn(2, align='|c|', data="Pilot 1"),
     MultiColumn(2, align='|c', data="Pilot 2")))
tabr.add_hline(start=2, end=9, cmidruleoption="lr")
tabr.add_row([""] + 4 * ["Coeff.", "p-val."])
tabr.add_hline()

# specify format
fmt = "{:.3f}"

# fill in the rows for each combination method (-3 for individuals)
for i in range(3):
    tabr.add_row([output_table.index[i]] +
                 [fmt.format(item) for item in output_table.iloc[i, :]])

# end of table
tabr.add_hline()
tabr.add_hline()

# add tabular to table
tabl.append(tabr)

# export the table
tabl.generate_tex(table_path + "output_table")

###############
# END OF FILE #
###############