out[ ]retired information requested attorney homemaker physician information requested per best efforts engineer teacher consultant professor you will notice by looking at the occupations that many refer to the same basic job typeor there are several variants of the same thing here is code snippet illustrates technique for cleaning up few of them by mapping from one occupation to anothernote the "trickof using dict get to allow occupations with no mapping to "pass through"occ_mapping 'information requested per best efforts'not provided''information requested'not provided''information requested (best efforts)'not provided'' ''ceoif no mapping providedreturn lambda xocc_mapping get(xxfec contbr_occupation fec contbr_occupation map(fi'll also do the same thing for employersemp_mapping 'information requested per best efforts'not provided''information requested'not provided''self'self-employed''self employed'self-employed'if no mapping providedreturn lambda xemp_mapping get(xxfec contbr_employer fec contbr_employer map(fnowyou can use pivot_table to aggregate the data by party and occupationthen filter down to the subset that donated at least $ million overallin [ ]by_occupation fec pivot_table('contb_receipt_amt'rows='contbr_occupation'cols='party'aggfunc='sum'in [ ]over_ mm by_occupation[by_occupation sum( in [ ]over_ mm out[ ]party contbr_occupation democrat republican example federal election commission database www it-ebooks info