def get_targets(self, company_ids: list) -> List[IDataProviderTarget]: """ Get all relevant targets for a list of company ids (ISIN). This method should return a list of IDataProviderTarget instances. :param company_ids: A list of company IDs (ISINs) :return: A list containing the targets """ targets = self.data_targets.to_dict(orient="records") model_targets: List[IDataProviderTarget] = [ IDataProviderTarget.parse_obj(target) for target in targets ] model_targets = [ target for target in model_targets if target.company_id in company_ids ] return model_targets
def _target_df_to_model(self, df_targets): """ transforms target Dataframe into list of IDataProviderTarget instances :param df_targets: pandas Dataframe with targets :return: A list containing the targets """ logger = logging.getLogger(__name__) targets = df_targets.to_dict(orient="records") model_targets: List[IDataProviderTarget] = [] for target in targets: try: model_targets.append(IDataProviderTarget.parse_obj(target)) except ValidationError as e: logger.warning( "(one of) the target(s) of company %s is invalid and will be skipped" % target[self.c.COMPANY_NAME]) pass return model_targets