DF_SGP_tot['Value_'] = DF_SGP_tot['SustG'] / DF_SGP_tot['PE_f12m'] DF_SGP_tot['freq'], DF_SGP_tot['StyleName'] = 'M', 'SGP_f2yr' # Append All Factors #*------------ firstCheck_duplicates(DF_PEf12m, DF_DYf12m, DF_EPS_fwd, DF_ROE_fwd, DF_EGP_tot, DF_SGP_tot, add_cols=['RGN_TP_CD']) #*------------ cols = [ 'BASE_DT', 'TMSRS_CD', 'Code', 'RGN_TP_CD', 'Value_', 'freq', 'StyleName' ] #*------------ secondCheck_columns(DF_PEf12m[cols], DF_DYf12m[cols], DF_EPS_fwd[cols], DF_ROE_fwd[cols], DF_EGP_tot[cols], DF_SGP_tot[cols]) #*------------ DF_GARP = reduce(lambda x, y: pd.DataFrame.append(x, y, sort=False), [ DF_PEf12m[cols], DF_DYf12m[cols], DF_EPS_fwd[cols], DF_ROE_fwd[cols], DF_EGP_tot[cols], DF_SGP_tot[cols] ]) DF_GARP.reset_index(drop=True, inplace=True) # Save! save_batch(bkfil, DF_GARP, mapping, fileName) from batch_utils.fill_monitor import print_fillReport out = print_fillReport(bkfil, freq, DF_GARP)
batch_monitor_msg(i, tot_n, st_time) batch_finish_msg(tot_n, st_time) DF_accruals_tot = substitute_Value(DF_accruals_yr, DF_accruals_qtr) DF_accrualsS_tot = substitute_Value(DF_accrualsS_yr, DF_accrualsS_qtr) #*------------ firstCheck_duplicates(DF_accruals_tot, DF_accrualsS_tot) #*------------ # Map Code -> TMSRS_CD # Should customize columns by needed ones. # MUST HAVE 'BASE_DT', 'TMSRS_CD', 'Code', 'Value_', 'RGN_TP_CD', 'freq' cols = [ 'BASE_DT', 'TMSRS_CD', 'Code', 'Value_yr', 'Value_qtr', 'Value_', 'RGN_TP_CD', 'freq', 'ref' ] DF_accruals_tot = add_mapped_tick(DF_accruals_tot, trim_codeMap)[cols] DF_accrualsS_tot = add_mapped_tick(DF_accrualsS_tot, trim_codeMap)[cols] DF_accruals_tot['StyleName'] = 'Accruals' DF_accrualsS_tot['StyleName'] = 'Accruals.S' #*------------ secondCheck_columns(DF_accruals_tot, DF_accrualsS_tot) #*------------ DF = DF_accruals_tot.append(DF_accrualsS_tot) # Save! save_batch(bkfil, DF, mapping, fileName) from batch_utils.fill_monitor import print_fillReport out = print_fillReport(bkfil, freq, DF)
DF_epsg_trail = add_mapped_tick(DF_epsg_trail, trim_codeMap)[cols] DF_ROE_trail['StyleName'] = 'ROE_l2yr' DF_Payout_trail['StyleName'] = 'Payout_l2yr' DF_epsg_trail['StyleName'] = 'EPSg_l2yr' #*------------ secondCheck_columns(DF_ROE_trail, DF_Payout_trail, DF_epsg_trail) #*------------ DF = reduce(lambda x, y: pd.DataFrame.append(x, y, sort=False), [DF_ROE_trail, DF_Payout_trail]) DF.reset_index(drop=True, inplace=True) # Save! save_batch(bkfil, DF, mapping, fileName + '_ROEnPayout') # Save! save_batch(bkfil, DF_epsg_trail, mapping, fileName + '_EPSg') from batch_utils.fill_monitor import print_fillReport out = print_fillReport(bkfil, freq, DF) out = print_fillReport(bkfil, freq, DF_epsg_trail) # <<Sustainable Growth Script>> dir_ = 'save_total' if bkfil else 'save_batch' DF_IBES_Payout = pd.read_pickle('{}/IBES_refIBES_Payout.p'.format(dir_)) DF_IBES_ROE = pd.read_pickle('{}/IBES_refIBES_ROE.p'.format(dir_)) # Merge IBES with Worldscope for (normalized) Payout & ROE (comb. average) TMP = DF_IBES_Payout[['BASE_DT', 'TMSRS_CD',
TMP['freq'] = 'curr' DF_Value = reduce(lambda x, y: pd.DataFrame.append(x, y, sort=True), [DF_Value, TMP, ps_DF, pfcf_DF]) batch_monitor_msg(i, tot_n, st_time) batch_finish_msg(tot_n, st_time) #*------------ firstCheck_duplicates(DF_Value, add_cols=['Name']) #*------------ # Map Code -> TMSRS_CD # Should customize columns by needed ones. # MUST HAVE 'BASE_DT', 'TMSRS_CD', 'Code', 'Value_', 'RGN_TP_CD', 'freq' cols = ['BASE_DT', 'TMSRS_CD', 'Code', 'Value_', 'RGN_TP_CD', 'freq', 'Name'] DF_Value = DF_Value.groupby('Name').apply( lambda x: add_mapped_tick(x, trim_codeMap)) DF_Value.index = DF_Value.index.droplevel(level=1) DF_Value.reset_index(drop=True, inplace=True) DF_Value = DF_Value[cols] DF_Value.rename(columns={'Name': 'StyleName'}, inplace=True) DF_Value['ref'] = None #*------------ secondCheck_columns(DF_Value) #*------------ # Save! save_batch(bkfil, DF_Value, mapping, fileName) from batch_utils.fill_monitor import print_fillReport out = print_fillReport(bkfil, freq, DF_Value)
TMP = reduce(lambda x, y: pd.DataFrame.append(x, y, sort=False), [ get_value_col(TMP0, 'Payout_fy0'), get_value_col(TMP1, 'Payout_fy1'), get_value_col(TMP2, 'Payout_fy2') ]) tmp_ = TMP.groupby(['BASE_DT', 'TMSRS_CD'], as_index=False)['Value_'].count() TMP = TMP.merge(tmp_.rename(columns={'Value_': 'CNT'}), on=['BASE_DT', 'TMSRS_CD']) TMP_ = TMP[TMP['CNT'] >= 2] Payout_mean = TMP_.groupby(['BASE_DT', 'TMSRS_CD'], as_index=False)['Value_'].mean() Payout_mean.rename(columns={'Value_': 'Payout_avg'}, inplace=True) # END AVERAGE calculation------- DF_IBES_Payout = pd.merge(DF_IBES_Payout, Payout_mean, on=['BASE_DT', 'TMSRS_CD'], how='left') DF_IBES_Payout['StyleName'] = 'IBES_Payout' save_batch(bkfil, DF_IBES_EPS, mapping, fileName[:-4] + '_EPS') save_batch(bkfil, DF_IBES_DPS, mapping, fileName[:-4] + '_DPS') save_batch(bkfil, DF_IBES_Payout, mapping, fileName[:-4] + '_Payout') from batch_utils.fill_monitor import print_fillReport out = print_fillReport(bkfil, freq, DF_IBES_EPS) out = print_fillReport(bkfil, freq, DF_IBES_DPS) out = print_fillReport(bkfil, freq, DF_IBES_Payout, chk_col='Payout_fy1')
['Code', 'RGN_TP_CD', 'BASE_DT']).reset_index(drop=True) #*------------ firstCheck_duplicates(DF_IBES_EPS, add_cols=['RGN_TP_CD']) #*------------ DF_IBES_EPS = chg_to_type(DF_IBES_EPS, chg_col=['Code', 'BASE_DT', 'RGN_TP_CD']) DF_IBES_EPS = add_mapped_tick( DF_IBES_EPS, trim_codeMap, on=['Code', 'RGN_TP_CD']) cols = ['BASE_DT', 'TMSRS_CD', 'Code', 'RGN_TP_CD', 'FY0', 'Px0', 'ActValue0', 'EPS_fy1', 'EPS_fy1_prev', 'EPS_chg_pct'] DF_IBES_EPS.dropna(subset=['EPS_chg_pct'], axis=0, inplace=True) DF_IBES_EPS = DF_IBES_EPS[cols] cols = ['BASE_DT', 'TMSRS_CD', 'Code', 'RGN_TP_CD', 'EPS_fy1', 'EPS_fy1_prev', 'EPS_chg_pct'] DF_final = DF_IBES_EPS[cols].copy() DF_final['freq'], DF_final['ref'] = 'M', None DF_final.rename(columns={'EPS_chg_pct': 'Value_'}, inplace=True) DF_final['StyleName'] = 'EPSRev3M' #*------------ secondCheck_columns(DF_final) #*------------ save_batch(bkfil, DF_final, mapping, fileName + '3M') from batch_utils.fill_monitor import print_fillReport out = print_fillReport(bkfil, freq, DF_final)