def _filter_by_agency(self):
if self.agency_ids_to_preserve is not None:<EOL><INDENT>logging.info("<STR_LIT>")<EOL>agency_ids_to_preserve = list(self.agency_ids_to_preserve)<EOL>agencies = pandas.read_sql("<STR_LIT>", self.copy_db_conn)<EOL>agencies_to_remove = []<EOL>for idx, row in agencies.iterrows():<EOL><INDENT>if row['<STR_LIT>'] not in agency_ids_to_preserve:<EOL><INDENT>agencies_to_remove.append(row['<STR_LIT>'])<EOL><DEDENT><DEDENT>for agency_id in agencies_to_remove:<EOL><INDENT>self.copy_db_conn.execute('<STR_LIT>', (agency_id,))<EOL><DEDENT>self.copy_db_conn.execute('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self.copy_db_conn.execute('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self.copy_db_conn.execute('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self.copy_db_conn.execute('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self.copy_db_conn.execute('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self.copy_db_conn.execute('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self.copy_db_conn.execute('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self.copy_db_conn.execute('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self.copy_db_conn.execute('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self.copy_db_conn.commit()<EOL>return FILTERED<EOL><DEDENT>else:<EOL><INDENT>return NOT_FILTERED<EOL><DEDENT>
filter by agency ids
:param copy_db_conn:
:param agency_ids_to_preserve:
:return: