def get_species(taxdump_file, select_divisions=None,<EOL>exclude_divisions=None, nrows=None):
if select_divisions and exclude_divisions:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>select_taxon_ids = _get_species_taxon_ids(<EOL>taxdump_file,<EOL>select_divisions=select_divisions,<EOL>exclude_divisions=exclude_divisions)<EOL>select_taxon_ids = set(select_taxon_ids)<EOL>with tarfile.open(taxdump_file) as tf:<EOL><INDENT>with tf.extractfile('<STR_LIT>') as fh:    <EOL><INDENT>df = pd.read_csv(fh, header=None, sep='<STR_LIT:|>',<EOL>encoding='<STR_LIT:ascii>', nrows=nrows)<EOL><DEDENT><DEDENT>df = df.iloc[:, [<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:3>]]<EOL>df = df.loc[df.iloc[:, <NUM_LIT:0>].isin(select_taxon_ids)]<EOL>df.iloc[:, <NUM_LIT:2>] = df.iloc[:, <NUM_LIT:2>].str.strip('<STR_LIT:\t>')<EOL>df = df.loc[df.iloc[:, <NUM_LIT:2>].isin(['<STR_LIT>', '<STR_LIT>'])]<EOL>df.iloc[:, <NUM_LIT:1>] = df.iloc[:, <NUM_LIT:1>].str.strip('<STR_LIT:\t>')<EOL>common_names = defaultdict(list)<EOL>cn = df.loc[df.iloc[:, <NUM_LIT:2>] == '<STR_LIT>']<EOL>for _, row in cn.iterrows():<EOL><INDENT>common_names[row.iloc[<NUM_LIT:0>]].append(row.iloc[<NUM_LIT:1>])<EOL><DEDENT>sn = df.loc[df.iloc[:, <NUM_LIT:2>] == '<STR_LIT>']<EOL>species = []<EOL>for i, row in sn.iterrows():<EOL><INDENT>species.append([row.iloc[<NUM_LIT:0>], row.iloc[<NUM_LIT:1>],<EOL>'<STR_LIT:|>'.join(common_names[row.iloc[<NUM_LIT:0>]])])<EOL><DEDENT>species_df = pd.DataFrame(species).set_index(<NUM_LIT:0>)<EOL>species_df.columns = ['<STR_LIT>', '<STR_LIT>']<EOL>species_df.index.name = '<STR_LIT>'<EOL>return species_df<EOL>
Get a dataframe with species information.