def op(self, data): for date, row in data.iterrows(): try: if util.isSameQuarter(date, util.FirstQuarter): self.processFirstQuarter(data, date, row) elif util.isSameQuarter(date, util.SecondQuarter): self.processSecondQuarter(data, date, row) elif util.isSameQuarter(date, util.ThirdQuarter): self.processThirdQuarter(data, date, row) else: self.processFourthQuarter(data, date, row) except TypeError as e: print(e) except KeyError as e: print(e)
def op(self, data): for date, row in data.iterrows(): if util.isSameQuarter(date, util.FirstQuarter): data.loc[date, self.keyQ] = 1 else: firstQuarter = util.getFirstQuarter(date) try: firstData = data.loc[firstQuarter] firstQuarterProfit = firstData.loc[KN['QuarterProfit']] try: if firstQuarterProfit > 0: data.loc[date, self.keyQ] = data.loc[ date, KN['QuarterProfit']] / firstQuarterProfit else: data.loc[date, self.keyQ] = 1 if util.isSameQuarter(date, util.FourthQuarter): priorDate = priorQ(date) priorData = data.loc[priorDate] yearProfit = row[KEY_NAME['jbmgsy']] threeQuarterProfit = priorData.loc[ KEY_NAME['jbmgsy']] if not util.isnan(threeQuarterProfit): if threeQuarterProfit > 0: data.loc[date, self.keyT] = ( yearProfit - threeQuarterProfit ) / threeQuarterProfit else: data.loc[date, self.keyT] = float(1) / float(3) prior2Date = priorXQ(date, 2) prior2Data = data.loc[prior2Date] halfYearQuarterProfit = prior2Data.loc[ KEY_NAME['jbmgsy']] if not util.isnan(halfYearQuarterProfit): if halfYearQuarterProfit > 0: data.loc[date, self.keyH] = ( yearProfit - halfYearQuarterProfit ) / halfYearQuarterProfit else: data.loc[date, self.keyH] = 1 except TypeError as e: print(e) except KeyError as e: print(e)
def op(self, data): for date, row in data.iterrows(): try: if util.isSameQuarter(date, util.FirstQuarter): data.loc[date, self.key] = row[ADJUST_NAME['ForecastProfit']] else: data.loc[date, self.key] = row[ADJUST_NAME['ForecastProfit']] -\ data.loc[priorQ(date), KEY_NAME['jbmgsy']] except KeyError as e: print(e) except TypeError as e: print(e)
def op(self, data): for date, row in data.iterrows(): try: profit = row[const.CWSJ_KEYWORD.KEY_NAME['jbmgsy']] if util.isSameQuarter(date, util.FirstQuarter): data.loc[date, const.CWSJ_KEYWORD. ADJUST_NAME['QuarterProfit']] = profit else: priorDate = priorQ(date) priorData = data.loc[priorDate] try: data.loc[date, const.CWSJ_KEYWORD.ADJUST_NAME[ 'QuarterProfit']] = profit - priorData.loc[ const.CWSJ_KEYWORD.KEY_NAME['jbmgsy']] except TypeError as e: print(e) except KeyError as e: print(e)