Individual Campaign Finance Contributions from FEC Data

The following Python code does some preliminary exploration of campaign finance data from the Federal Election Committee (FEC) website. It requires that the following three files be downloaded and unzipped and placed in the specified directories (relative to the notebook)

Candidate master for 2017-2018 - unzip and place cn.txt in directory fec/cm18/

Committee master for 2017-2018 - unzip and place cm.txt in directory fec/cn18/

Contributions by individuals for 2017-2018 - unzip and place itcont.txt in directory fec/indiv18/

Load all Individual Contributions and Merge Information from Committee and Candidate Tables.

The individual contribution table is very large. It will be loaded into object ii and only reloaded if ii doesn't exist. The following code will create ii if it doesn't exist and output the first row to show all available fields:

In [50]:
import pandas as pd
pd.set_option('display.width', 220)
pd.set_option('max_rows', 200)

year = 2018
try:
    ii
except NameError:
    yr = year % 100
    filepath = "fec/indiv" + str(yr) + "/itcont.txt"
    hdr = pd.read_csv("https://www.fec.gov/files/bulk-downloads/data_dictionaries/indiv_header_file.csv", skiprows=0)
    print("READING "+filepath)
    ii = pd.read_table(filepath, sep='|', header=None, names=hdr)
    print(ii.shape)
    hdr = pd.read_csv("https://www.fec.gov/data/advanced/files/bulk-downloads/data_dictionaries/cm_header_file.csv", skiprows=0)
    cm = pd.read_table("fec/cm" + str(yr) + "/cm.txt", sep='|', header=None, names=hdr.columns)
    hdr = pd.read_csv("https://www.fec.gov/data/advanced/files/bulk-downloads/data_dictionaries/cn_header_file.csv", skiprows=0)
    cn = pd.read_table("fec/cn" + str(yr) + "/cn.txt", sep='|', header=None, names=hdr.columns)
    ii=ii.merge(cm, left_on='CMTE_ID', right_on='CMTE_ID')
    ii=ii.merge(cn, left_on='CAND_ID', right_on='CAND_ID', how='left')
    ii['TRANSACTION_DT'] = ii['TRANSACTION_DT'].fillna(0).astype(int)
    ii['TRANSACTION_DT'] = pd.to_datetime(ii['TRANSACTION_DT'],format='%m%d%Y',errors='coerce')
    ii.rename(columns={'TRANSACTION_DT':'DATE', 'TRANSACTION_AMT':'AMT', 'CAND_PTY_AFFILIATION':'PARTY'}, inplace=True)
    #ii['AMOUNT'] = ii['AMT'].apply(lambda x: '{:,}'.format(x))
print(ii.iloc[0,:])
CMTE_ID                                        C00629618
AMNDT_IND                                              N
RPT_TP                                               TER
TRANSACTION_PGI                                        P
IMAGE_NUM                             201701230300133512
TRANSACTION_TP                                       15C
ENTITY_TP                                            IND
NAME                                       PEREZ, JOHN A
CITY                                         LOS ANGELES
STATE                                                 CA
ZIP_CODE                                           90017
EMPLOYER                                       PRINCIPAL
OCCUPATION                        DOUBLE NICKEL ADVISORS
DATE                                 2017-10-03 00:00:00
AMT                                                   40
OTHER_ID                                       H6CA34245
TRAN_ID                                    SA01251735122
FILE_NUM                                         1141239
MEMO_CD                                              NaN
MEMO_TEXT                                            NaN
SUB_ID                               2012520171368850783
CMTE_NM                        JOHN A PEREZ FOR CONGRESS
TRES_NM                                STEPHEN J KAUFMAN
CMTE_ST1                777 S FIGUEROA STREET SUITE 4050
CMTE_ST2                                             NaN
CMTE_CITY                                    LOS ANGELES
CMTE_ST                                               CA
CMTE_ZIP                                           90017
CMTE_DSGN                                              P
CMTE_TP                                                H
CMTE_PTY_AFFILIATION                                 DEM
CMTE_FILING_FREQ                                       T
ORG_TP                                               NaN
CONNECTED_ORG_NM                                     NaN
CAND_ID                                        H6CA34245
CAND_NAME                                  PEREZ, JOHN A
PARTY                                                DEM
CAND_ELECTION_YR                                    2017
CAND_OFFICE_ST                                        CA
CAND_OFFICE                                            H
CAND_OFFICE_DISTRICT                                  34
CAND_ICI                                               O
CAND_STATUS                                            N
CAND_PCC                                       C00629618
CAND_ST1                777 S FIGUEROA STREET SUITE 4050
CAND_ST2                                             NaN
CAND_CITY                                    LOS ANGELES
CAND_ST                                               CA
CAND_ZIP                                           90017
Name: 0, dtype: object

Largest Individual Contributions Grouped by the Name, City, and State of the Contributor

The following code aggregates the individual contributions by the name, city, and state of the contributor to get an initial estimate of the total contributions made by each contributor. This is only an initial estimate because, if a single contributor should vary or misspell any of these items, those contributions will be grouped separately. For example, note that items 3, 10, 37, 40, and 43 all appear to be for the same contributor, Richard Uihlein of Lake Forest, IL. The names listed are UIHLEIN, RICHARD; UIHLEIN, RICHARD E.; UIHLEIN, RICHARD E.; UIHLEIN, RICHARD and UIHLEIN, RICHARD E. MR. Of these, only the first and fourth and the second and third appear to be the same. However, the first (item 3) and fourth (item 40) differ in that the first state is IL and the second state is IN. Then, the second (item 10) and third (item 37) differ because the latter item misspells the city as LAKE FORST. In any event, the final total following the table shows that over $1.9 billion has already been contributed to federal candidates, PACs, and other committees.

In [51]:
jj = ii.groupby(['NAME','CITY','STATE'])['AMT'].agg(['sum'])
jj = jj.reset_index(level=['NAME','CITY','STATE'])
jj.columns = ['NAME','CITY','STATE','AMT']
jj['AMOUNT'] = jj['AMT'].apply(lambda x: '{:,}'.format(x))
jj = jj.sort_values(by='AMT',ascending=False)
jj.index = range(1,len(jj)+1)
print(jj[['NAME','CITY','STATE','AMOUNT']].head(100))
print('\nTOTAL = ' + '{:,}'.format(sum(jj['AMT'])))
                                                  NAME             CITY STATE      AMOUNT
1                                    STEYER, THOMAS F.    SAN FRANCISCO    CA  15,743,487
2                              AMERICAN ACTION NETWORK       WASHINGTON    DC  15,290,970
3                                     UIHLEIN, RICHARD      LAKE FOREST    IL  13,229,800
4         UNITED BROTHERHOOD OF CARPENTERS AND JOINERS       WASHINGTON    DC   9,779,385
5                     REPUBLICAN GOVERNORS ASSOCIATION       WASHINGTON    DC   7,466,173
6               DEMOCRATIC GOVERNORS ASSOCIATION (DGA)       WASHINGTON    DC   7,177,000
7                                      WALL, KATHALEEN          HOUSTON    TX   6,000,557
8                                   AFT SOLIDARITY 527       WASHINGTON    DC   5,100,000
9                                       EYCHANER, FRED          CHICAGO    IL   4,825,300
10                                 UIHLEIN, RICHARD E.      LAKE FOREST    IL   4,761,200
11                                 MARCUS, BERNARD MR.          ATLANTA    GA   4,342,000
12                                   MARCUS, GEORGE M.        PALO ALTO    CA   3,796,200
13                                  SUSSMAN, S. DONALD  FORT LAUDERDALE    FL   3,277,000
14                                                 SMP       WASHINGTON    DC   3,196,230
15                          CHARLES G. KOCH 1997 TRUST          WICHITA    KS   3,000,000
16                                       LAUFER, HENRY          LANTANA    FL   2,963,000
17                                          DAGA, INC.       WASHINGTON    DC   2,888,297
18                                          MOODY, DAN          ROSWELL    GA   2,803,120
19                              AFSCME SPECIAL ACCOUNT       WASHINGTON    DC   2,592,561
20                       FLINN, GEORGE S DR JR S JR DR          MEMPHIS    TN   2,545,000
21                                     WEXNER, ABIGAIL       NEW ALBANY    OH   2,526,200
22                                        TRONE, DAVID         BETHESDA    MD   2,515,739
23                                       SOROS, GEORGE         NEW YORK    NY   2,385,964
24                                 PALMER, GEOFFREY H.    BEVERLY HILLS    CA   2,000,000
25                                COHEN, STEVEN A. MR.         STAMFORD    CT   2,000,000
26                    HILLWOOD DEVELOPMENT COMPANY LLC           DALLAS    TX   2,000,000
27   GREATER NEW YORK HOSPITAL ASSOCIATION MANAGEME...         NEW YORK    NY   2,000,000
28                                    SIMONS, JAMES H.         NEW YORK    NY   1,827,500
29                                 UNITED STEELWORKERS       PITTSBURGH    PA   1,750,091
30                                    SIMON, DEBORAH J           CARMEL    IN   1,712,600
31                                 AYYADURAI, SHIVA DR        CAMBRIDGE    MA   1,705,747
32                               SKJODT, CYNTHIA SIMON           CARMEL    IN   1,688,000
33                              SUSSMAN, SELWYN DONALD         PORTLAND    ME   1,674,100
34                   COMMUNICATIONS WORKERS OF AMERICA       WASHINGTON    DC   1,625,611
35                                     ANSARY, HUSHANG          HOUSTON    TX   1,621,200
36                                       KERR, PAUL G.        SAN DIEGO    CA   1,618,102
37                                 UIHLEIN, RICHARD E.       LAKE FORST    IL   1,550,000
38                                     FOSTER, PAUL L.          EL PASO    TX   1,505,800
39                             SOLUTIONS FOR WISCONSIN           AUSTIN    TX   1,500,000
40                                    UIHLEIN, RICHARD      LAKE FOREST    IN   1,500,000
41                                VALERO SERVICES INC.      SAN ANTONIO    TX   1,500,000
42       LABORERS' POLITICAL LEAGUE GREAT LAKES REGION          CHICAGO    IL   1,450,000
43                             UIHLEIN, RICHARD E. MR.      LAKE FOREST    IL   1,444,400
44                                SCHWARTZ, BERNARD L.         NEW YORK    NY   1,312,700
45                         TARGETED PLATFORM MEDIA LLC        ANNAPOLIS    MD   1,261,553
46                                      SIMON, DEBORAH           CARMEL    IN   1,187,253
47                   PINNACLE WEST CAPITAL CORPORATION          PHOENIX    AZ   1,150,000
48                                FERTITTA, LORENZO J.        LAS VEGAS    NV   1,150,000
49                                        BEAL, ANDREW            PLANO    TX   1,124,200
50                                        JACOBS, SARA          DEL MAR    CA   1,103,228
51                                    COHEN, STEVEN A.        GREENWICH    CT   1,100,000
52                                     MARCUS, BERNARD          ATLANTA    GA   1,067,500
53                                    REINSDORF, JERRY          CHICAGO    IL   1,058,200
54                             GRIFFIN, KENNETH C. MR.          CHICAGO    IL   1,049,200
55                                 JOHNSON, CHARLES B.       PALM BEACH    FL   1,048,900
56                                   SIMON, DEBORAH J.           CARMEL    IN   1,046,750
57                                  ROSENTHAL, RICHARD       CINCINNATI    OH   1,024,300
58                               SIMON-SKJODT, CYNTHIA           CARMEL    IN   1,005,400
59                               SIMON SKJODT, CYNTHIA           CARMEL    IN   1,002,700
60                                      NEXTERA ENERGY       JUNO BEACH    FL   1,001,000
61                                    MATHILE, CLAYTON           DAYTON    OH   1,000,000
62          CHEVRON POLICY GOVERNMENT & PUBLIC AFFAIRS        SAN RAMON    CA   1,000,000
63                                    TESORO COMPANIES      SAN ANTONIO    TX   1,000,000
64                               AI ALTEP HOLDINGS INC         NEW YORK    NY   1,000,000
65                                MELLON, MATTHEW T II         NEW YORK    NY   1,000,000
66                               FERTITTA, FRANK J III        LAS VEGAS    NV   1,000,000
67                            MERCER, ROBERT LEROY MR.        ST. JAMES    NY   1,000,000
68                                SINGER, PAUL ELLIOTT         NEW YORK    NY   1,000,000
69                           MURRAY ENERGY CORPORATION        BEACHWOOD    OH   1,000,000
70                             GILLIAM, RICHARD B. MR.          KESWICK    VA   1,000,000
71                     NATIONAL EDUCATION, ASSOCIATION       WASHINGTON    DC   1,000,000
72                                          YASS, JEFF     BALA CYNWYND    PA   1,000,000
73                                       HOFFMAN, REID    SAN FRANCISCO    CA     983,108
74                                ANSARY, HUSHANG HON.          HOUSTON    TX     969,500
75                          CANSECO, FRANCISCO 'QUICO'      SAN ANTONIO    TX     964,855
76                                      LINDBERG, GREG           DURHAM    NC     937,400
77                                        TAYLOR, DALE          CHICAGO    IL     925,211
78                               PRIORITIES USA ACTION       WASHINGTON    DC     925,000
79   UNITED FOOD AND COMMERCIAL WORKERS INTERNATION...       WASHINGTON    DC     920,475
80          INTERNATIONAL UNION OF OPERATING ENGINEERS       WASHINGTON    DC     907,485
81                        OHIO ASSOCIATION OF REALTORS         COLUMBUS    OH     907,350
82                                        LYNCH, HOLLY         NEW YORK    NY     841,734
83                                      SHAW, DAVID E.         NEW YORK    NY     835,600
84                              WRIGHT, KAREN BUCHWALD     MOUNT VERNON    OH     810,750
85                           IBEW PAC EDUCATIONAL FUND       WASHINGTON    DC     790,000
86                            FERTITTA, LORENZO J. MR.        LAS VEGAS    NV     787,000
87                          FERTITTA, FRANK J. MR. III        LAS VEGAS    NV     787,000
88                               OBERNDORF, WILLIAM E.    SAN FRANCISCO    CA     777,000
89                        POARCH BAND OF CREEK INDIANS           ATMORE    AL     770,858
90                                 ALLIED WALLET, INC.   WEST HOLLYWOOD    CA     750,000
91           LABORERS' POLITICAL LEAGUE EDUCATION FUND       WASHINGTON    DC     750,000
92                            DUCHOSSOIS, CRAIG J. MR.          CHICAGO    IL     747,700
93                              BROWN, SHAUN DENISE MS   VIRGINIA BEACH    VA     745,781
94                      KEVIN DE LEON FOR STATE SENATE       LONG BEACH    CA     722,844
95                                             CHEVRON          CONCORD    CA     700,000
96                                   HAYDE, MICHAEL K.           IRVINE    CA     696,000
97                                        STRYKER, PAT     FORT COLLINS    CO     693,200
98                                      HUNT, WOODY L.          EL PASO    TX     665,600
99                                           GOPAC INC        ARLINGTON    VA     656,300
100                                         TUNA, CARI    SAN FRANCISCO    CA     653,480

TOTAL = 1,939,128,309

Largest Individual Contributions Grouped by Committees Connected to Specific Candidates

In [52]:
jj = ii[pd.notnull(ii['CAND_ID'])]
jj = jj.groupby(['CMTE_NM','CAND_NAME','PARTY'])['AMT'].agg(['sum'])
jj = jj.reset_index(level=['CMTE_NM','CAND_NAME','PARTY'])
jj.columns = ['CMTE_NM','CAND_NAME','PARTY','AMT']
jj['AMOUNT'] = jj['AMT'].apply(lambda x: '{:,}'.format(x))
jj = jj.sort_values(by='AMT',ascending=False)
jj.index = range(1,len(jj)+1)
print(jj[['CMTE_NM','CAND_NAME','PARTY','AMOUNT']].head(100))
print('\nTOTAL = ' + '{:,}'.format(sum(jj['AMT'])))
                                          CMTE_NM                      CAND_NAME PARTY      AMOUNT
1                                       TEAM RYAN                  RYAN, PAUL D.   REP  47,635,251
2                 DOUG JONES FOR SENATE COMMITTEE                    JONES, DOUG   DEM  14,836,339
3                         MCCASKILL FOR MISSOURI               MCCASKILL, CLAIRE   DEM  12,290,297
4                         JON OSSOFF FOR CONGRESS            OSSOFF, T. JONATHAN   DEM  11,017,533
5                           GILLIBRAND FOR SENATE  GILLIBRAND, KIRSTEN ELIZABETH   DEM  10,349,232
6                           MCCARTHY VICTORY FUND                MCCARTHY, KEVIN   REP   9,578,875
7                        FRIENDS OF SHERROD BROWN                 BROWN, SHERROD   DEM   9,458,186
8                        TAMMY BALDWIN FOR SENATE                 BALDWIN, TAMMY   DEM   7,179,935
9                      BILL NELSON FOR U S SENATE                   NELSON, BILL   DEM   6,294,430
10                      CORNYN MAJORITY COMMITTEE                   CORNYN, JOHN   REP   6,053,663
11                    KATHALEEN WALL FOR CONGRESS           WALL, KATHALEEN MRS.   REP   5,946,877
12                       BOB CASEY FOR SENATE INC             CASEY, ROBERT P JR   DEM   5,838,683
13                                 BETO FOR TEXAS        O'ROURKE, ROBERT (BETO)   DEM   5,370,099
14                        SCALISE LEADERSHIP FUND              SCALISE, STEVE MR   REP   4,444,980
15                             KAINE FOR VIRGINIA         KAINE, TIMOTHY MICHAEL   DEM   4,280,216
16                           ELIZABETH FOR MA INC              WARREN, ELIZABETH   DEM   4,190,848
17            DONALD J. TRUMP FOR PRESIDENT, INC.                TRUMP, DONALD J   REP   4,119,461
18                           MONTANANS FOR TESTER                    TESTER, JON   DEM   4,108,958
19                        FRIENDS OF CHRIS MURPHY       MURPHY, CHRISTOPHER S MR   DEM   4,028,585
20                         STABENOW FOR US SENATE               STABENOW, DEBBIE   DEM   3,930,587
21                               FRIENDS OF MARIA                CANTWELL, MARIA   DEM   3,878,647
22                                      TEAM JOSH                   MANDEL, JOSH   REP   3,741,515
23                               HEIDI FOR SENATE                HEITKAMP, HEIDI   DEM   3,552,734
24                   JEFF FLAKE FOR US SENATE INC                    FLAKE, JEFF   REP   3,484,699
25                      HANDEL FOR CONGRESS, INC.        HANDEL, KAREN CHRISTINE   REP   3,331,693
26                     TED CRUZ VICTORY COMMITTEE        CRUZ, RAFAEL EDWARD TED   REP   3,047,489
27                  JUDGE ROY MOORE FOR US SENATE               MOORE, ROY JUDGE   REP   3,010,875
28                            TED CRUZ FOR SENATE        CRUZ, RAFAEL EDWARD TED   REP   2,996,216
29                   DAN MOODY FOR CONGRESS, INC.                     MOODY, DAN   REP   2,957,283
30                       KLOBUCHAR FOR MINNESOTA                  KLOBUCHAR, AMY   DEM   2,947,276
31                               GREG FOR MONTANA                GIANFORTE, GREG   REP   2,753,354
32                           DONNELLY FOR INDIANA             DONNELLY, JOSEPH S   DEM   2,723,701
33                   HATCH ELECTION COMMITTEE INC                 HATCH, ORRIN G   REP   2,709,882
34                               ROSEN FOR NEVADA                   ROSEN, JACKY   DEM   2,694,142
35                      NANCY PELOSI VICTORY FUND                  PELOSI, NANCY   DEM   2,672,539
36                   OHIO GRASSROOTS VICTORY FUND                 BROWN, SHERROD   DEM   2,621,340
37                        CONOR LAMB FOR CONGRESS                    LAMB, CONOR   DEM   2,609,760
38                              WICKER FOR SENATE                WICKER, ROGER F   REP   2,599,432
39                              HELLER FOR SENATE                   HELLER, DEAN   REP   2,572,305
40                        FRIENDS OF GEORGE FLINN          FLINN, GEORGE S DR JR   REP   2,545,300
41                  DAVID TRONE FOR CONGRESS, INC                   TRONE, DAVID   DEM   2,466,889
42                   FRIENDS OF RAJA FOR CONGRESS        KRISHNAMOORTHI, S. RAJA   DEM   2,447,871
43                 BOB CORKER FOR SENATE 2018 INC            CORKER, ROBERT P JR   REP   2,430,783
44                          WHITEHOUSE FOR SENATE         WHITEHOUSE, SHELDON II   DEM   2,287,863
45                            MENENDEZ FOR SENATE               MENENDEZ, ROBERT   DEM   2,284,075
46                             SINEMA FOR ARIZONA                SINEMA, KYRSTEN   DEM   2,231,007
47                                 SHIVA 4 SENATE           AYYADUSAI, SHIVA  DR   REP   2,119,526
48                   JOSH GOTTHEIMER FOR CONGRESS               GOTTHEIMER, JOSH   DEM   2,112,670
49                          ROB QUIST FOR MONTANA               QUIST, ROBERT E.   DEM   2,037,947
50                     MARTIN HEINRICH FOR SENATE        HEINRICH, MARTIN TREVOR   DEM   2,008,037
51                       FRIENDS OF JOHN BARRASSO               BARRASSO, JOHN A   REP   1,976,212
52                      FEINSTEIN FOR SENATE 2018              FEINSTEIN, DIANNE   DEM   1,964,417
53                              MARSHA FOR SENATE          BLACKBURN, MARSHA MRS   REP   1,946,495
54                           MCSALLY FOR CONGRESS                MCSALLY, MARTHA   REP   1,944,954
55                                 COTTON VICTORY                 COTTON, THOMAS   REP   1,938,469
56                         PAUL KERR FOR CONGRESS                     KERR, PAUL   DEM   1,935,372
57                   CITIZENS FOR JOSH MANDEL INC               MANDEL, JOSHUA A   REP   1,869,336
58   MCMORRIS RODGERS AMERICAN DREAM PROJECT; THE        MCMORRIS RODGERS, CATHY   REP   1,853,059
59                            RO FOR CONGRESS INC                  KHANNA, ROHIT   DEM   1,837,823
60                         FRIENDS OF MARK WARNER            WARNER, MARK ROBERT   DEM   1,829,545
61              ANGUS KING FOR US SENATE CAMPAIGN         KING, ANGUS STANLEY JR   IND   1,784,714
62                                TEAM GRAHAM INC              GRAHAM, LINDSEY O   REP   1,781,067
63                      HOOSIERS FOR ROKITA, INC.        ROKITA, THEODORE EDWARD   REP   1,737,997
64                             STRANGE FOR SENATE          STRANGE, LUTHER J III   REP   1,716,619
65                       ROYCE CAMPAIGN COMMITTEE                  ROYCE, ED MR.   REP   1,711,867
66                         JOSH HAWLEY FOR SENATE           HAWLEY, JOSHUA DAVID   REP   1,663,315
67                    BEN CARDIN FOR SENATE, INC.             CARDIN, BENJAMIN L   DEM   1,629,662
68                       SARA JACOBS FOR CONGRESS                   JACOBS, SARA   DEM   1,613,973
69                                    I LIKE LUKE            MESSER, ALLEN LUCAS   REP   1,591,618
70                            SCHIFF FOR CONGRESS                   SCHIFF, ADAM   DEM   1,527,748
71                      MANCHIN FOR WEST VIRGINIA               MANCHIN III, JOE   DEM   1,446,176
72                     CHARLIE CRIST FOR CONGRESS          CRIST, CHARLIE JOSEPH   DEM   1,433,185
73                     COMMITTEE TO ELECT DAN KOH             KOH, DANIEL ARRIGG   DEM   1,425,720
74                        FLAKE VICTORY COMMITTEE                    FLAKE, JEFF   REP   1,420,232
75                          BARTOS FOR SENATE INC              BARTOS, JEFFREY A   REP   1,384,961
76                     STEPHEN FINCHER FOR SENATE               FINCHER, STEPHEN   REP   1,367,902
77                         SCHNEIDER FOR CONGRESS       SCHNEIDER, BRADLEY SCOTT   DEM   1,362,577
78                           DELGADO FOR CONGRESS               DELGADO, ANTONIO   DEM   1,352,665
79                  ROSKAM FOR CONGRESS COMMITTEE                  ROSKAM, PETER   REP   1,348,810
80                          KEYSTONE VICTORY FUND             CASEY, ROBERT P JR   DEM   1,324,134
81                    SALUD CARBAJAL FOR CONGRESS                CARBAJAL, SALUD   DEM   1,280,765
82                            JOHN KENNEDY FOR US            KENNEDY, JOHN NEELY   REP   1,254,210
83                          BOOKER SENATE VICTORY                 BOOKER, CORY A   DEM   1,246,881
84                     BILL CASSIDY FOR US SENATE             CASSIDY, WILLIAM M   REP   1,229,178
85                      MIMI WALTERS VICTORY FUND                  WALTERS, MIMI   REP   1,214,792
86                            DUFFY FOR WISCONSIN                    DUFFY, SEAN   REP   1,191,994
87                    ROBERT LEE AHN FOR CONGRESS                AHN, ROBERT LEE   DEM   1,190,524
88              SEAN PATRICK MALONEY FOR CONGRESS          MALONEY, SEAN PATRICK   DEM   1,172,286
89                        CROWLEY LEADERSHIP FUND                CROWLEY, JOSEPH   DEM   1,143,299
90                       JOE KENNEDY FOR CONGRESS          KENNEDY, JOSEPH P III   DEM   1,091,017
91                      RALPH NORMAN FOR CONGRESS           NORMAN, RALPH W. JR.   REP   1,089,306
92                             ERNST VICTORY IOWA                  ERNST, JONI K   REP   1,075,498
93                              MAST FOR CONGRESS                    MAST, BRIAN   REP   1,070,726
94                              DINO FOR CONGRESS                    ROSSI, DINO   REP   1,070,146
95                  DEB FISCHER FOR US SENATE INC               FISCHER, DEBRA S   REP   1,069,440
96                          MCCREADY FOR CONGRESS               MCCREADY, DANIEL   DEM   1,049,631
97                 DEVIN NUNES CAMPAIGN COMMITTEE            NUNES, DEVIN GERALD   REP   1,043,411
98                     DEAN PHILLIPS FOR CONGRESS                 PHILLIPS, DEAN   DFL   1,034,803
99                          POLIQUIN FOR CONGRESS              POLIQUIN, BRUCE L   REP   1,033,777
100                           ALISON FOR VIRGINIA               FRIEDMAN, ALISON   DEM   1,025,486

TOTAL = 665,461,258

Largest Individual Contributions Grouped by Committees Not Connected to Specific Candidates

In [53]:
jj = ii[pd.isnull(ii['CAND_ID'])]
jj = jj.groupby(['CMTE_NM'])['AMT'].agg(['sum'])
jj = jj.reset_index(level=['CMTE_NM'])
jj.columns = ['CMTE_NM','AMT']
jj['AMOUNT'] = jj['AMT'].apply(lambda x: '{:,}'.format(x))
jj = jj.sort_values(by='AMT',ascending=False)
jj.index = range(1,len(jj)+1)
print(jj[['CMTE_NM','AMOUNT']].head(100))
print('\nTOTAL = ' + '{:,}'.format(sum(jj['AMT'])))
                                               CMTE_NM       AMOUNT
1                                              ACTBLUE  212,966,091
2                        REPUBLICAN NATIONAL COMMITTEE   64,402,263
3                                                 DCCC   49,638,981
4                        CONGRESSIONAL LEADERSHIP FUND   33,823,523
5                                                 DSCC   31,760,217
6              DNC SERVICES CORP./DEM. NAT'L COMMITTEE   28,985,242
7                                                 NRSC   23,231,331
8                                        TRUMP VICTORY   22,961,326
9                                                  SMP   21,891,530
10                                                NRCC   19,116,614
11                              SENATE LEADERSHIP FUND   18,082,700
12                    NEXTGEN CLIMATE ACTION COMMITTEE   16,040,073
13                                        EMILY'S LIST   12,850,885
14                                  HOUSE MAJORITY PAC   10,429,614
15             WORKING FOR WORKING AMERICANS - FEDERAL    9,779,385
16                          AMERICA FIRST ACTION, INC.    8,500,222
17            TRUMP MAKE AMERICA GREAT AGAIN COMMITTEE    8,303,303
18                             RGA RIGHT DIRECTION PAC    7,466,173
19                        AMERICAN BRIDGE 21ST CENTURY    7,222,029
20                                          DGA ACTION    7,187,231
21                              CLUB FOR GROWTH ACTION    7,100,024
22   INTERNATIONAL BROTHERHOOD OF ELECTRICAL WORKER...    7,018,903
23                                      FOR OUR FUTURE    6,841,511
24                  FREEDOM PARTNERS ACTION FUND, INC.    6,310,500
25                                  KAINE VICTORY FUND    6,015,715
26                                 END CITIZENS UNITED    5,306,260
27                                   PROTECT THE HOUSE    5,115,671
28                  DEMOCRATIC GRASSROOTS VICTORY FUND    5,107,900
29                                     RESTORATION PAC    5,000,600
30                             CALIFORNIA VICTORY 2018    4,431,820
31                                          HIGHWAY 31    4,366,480
32                               WITH HONOR FUND, INC.    4,337,073
33                            PLANNED PARENTHOOD VOTES    4,297,868
34                               JOHN BOLTON SUPER PAC    3,890,658
35   HONEYWELL INTERNATIONAL POLITICAL ACTION COMMI...    3,544,805
36                     MASSACHUSETTS VICTORY COMMITTEE    3,522,300
37                             SOLUTIONS FOR WISCONSIN    3,500,000
38    NATIONAL AIR TRAFFIC CONTROLLERS ASSOCIATION PAC    3,438,930
39                        ELIZABETH WARREN ACTION FUND    3,420,583
40   AMERICAN ASSOCIATION FOR JUSTICE POLITICAL ACT...    3,304,858
41   NATIONAL ASSOCIATION OF REALTORS POLITICAL ACT...    3,288,903
42                              LIUNA BUILDING AMERICA    3,191,868
43                         PROGRESSIVE TURNOUT PROJECT    3,015,526
44                                                DAGA    2,984,191
45   NATIONAL BEER WHOLESALERS ASSOCIATION POLITICA...    2,951,750
46   PRICEWATERHOUSECOOPERS POLITICAL ACTION COMMIT...    2,948,225
47            ERNST & YOUNG POLITICAL ACTION COMMITTEE    2,943,331
48                 DELOITTE POLITICAL ACTION COMMITTEE    2,722,680
49   NATIONAL AUTOMOBILE DEALERS ASSOCIATION POLITI...    2,665,894
50                                        VOTESANE PAC    2,614,200
51               THE COMMITTEE TO DEFEND THE PRESIDENT    2,489,415
52       THE BOEING COMPANY POLITICAL ACTION COMMITTEE    2,468,912
53                   CITIZENS FOR A STRONG AMERICA INC    2,431,000
54                                        CHC BOLD PAC    2,430,082
55                                        GIFFORDS PAC    2,422,714
56                                        AMERICAS PAC    2,401,000
57                          SERVE AMERICA VICTORY FUND    2,222,887
58          KPMG PARTNERS/PRINCIPALS AND EMPLOYEES PAC    2,184,600
59   KOCH INDUSTRIES, INC. POLITICAL ACTION COMMITT...    2,157,562
60   COMCAST CORPORATION & NBCUNIVERSAL POLITICAL A...    2,111,351
61                         MOVEON.ORG POLITICAL ACTION    2,048,498
62                                 CFG ACTION MISSOURI    2,000,000
63                         FEARLESS FOR THE PEOPLE PAC    1,982,621
64   LOCKHEED MARTIN CORPORATION EMPLOYEES' POLITIC...    1,953,802
65   NJ STATE LABORERS PAC/ LABORERS' INTERNATIONAL...    1,916,951
66                                         WOMEN VOTE!    1,878,310
67                               PRIORITIES USA ACTION    1,833,284
68                                    PAC FOR A CHANGE    1,818,881
69   AMERICAN SOCIETY OF ANESTHESIOLOGISTS POLITICA...    1,782,733
70                                           USW WORKS    1,750,091
71   UNITEDHEALTH GROUP INCORPORATED PAC (UNITEDHEA...    1,739,367
72                    TEA PARTY PATRIOTS CITIZENS FUND    1,739,012
73                                          TEXANS ARE    1,734,600
74                                 CLUB FOR GROWTH PAC    1,712,257
75       EMPLOYEES OF NORTHROP GRUMMAN CORPORATION PAC    1,710,136
76           LEAGUE OF CONSERVATION VOTERS ACTION FUND    1,669,117
77                     OHIO CONSERVATIVES FOR A CHANGE    1,635,000
78    COMMUNICATIONS WORKERS OF AMERICA WORKING VOICES    1,625,611
79   ENTERPRISE HOLDINGS, INC. POLITICAL ACTION COM...    1,616,633
80   INTERNATIONAL ASSOCIATION OF FIREFIGHTERS INTE...    1,614,932
81   NATIONAL ASSOCIATION OF BROADCASTERS POLITICAL...    1,613,351
82   POLITICAL ACTION COMMITTEE OF THE AMERICAN ASS...    1,606,739
83                                          JSTREETPAC    1,605,351
84   AMERICAN CRYSTAL SUGAR COMPANY POLITICAL ACTIO...    1,602,271
85   NATIONAL MULTIFAMILY HOUSING COUNCIL POLITICAL...    1,596,956
86   THE COUNCIL OF INSURANCE AGENTS & BROKERS POLI...    1,577,027
87   BUILD POLITICAL ACTION COMMITTEE OF THE NATION...    1,569,407
88         BNSF RAILWAY COMPANY RAILPAC (BNSF RAILPAC)    1,560,262
89   AT&T INC. FEDERAL POLITICAL ACTION COMMITTEE (...    1,535,134
90                       ARIZONA GRASSROOTS ACTION PAC    1,527,000
91   UNION PACIFIC CORP. FUND FOR EFFECTIVE GOVERNMENT    1,525,516
92                           MICHIGAN REPUBLICAN PARTY    1,512,658
93                        REPUBLICAN PARTY OF KENTUCKY    1,481,425
94                                          SWING LEFT    1,479,316
95             AUTOMOTIVE FREE INTERNATIONAL TRADE PAC    1,441,535
96                             FORWARD MAJORITY ACTION    1,381,559
97                           SENATE CONSERVATIVES FUND    1,371,126
98                           UNITED FOR PROGRESS, INC.    1,336,000
99                                  HOUSE FREEDOM FUND    1,325,304
100  UBS AMERICAS INC. POLITICAL ACTION COMMITTEE (...    1,311,505

TOTAL = 1,276,875,080

Largest Individual Contributions Grouped by Candidates

In [54]:
jj = ii.groupby(['CAND_NAME','PARTY'])['AMT'].agg(['sum'])
jj = jj.reset_index(level=['CAND_NAME','PARTY'])
jj.columns = ['CAND_NAME','PARTY','AMT']
jj['AMOUNT'] = jj['AMT'].apply(lambda x: '{:,}'.format(x))
jj = jj.sort_values(by='AMT',ascending=False)
jj.index = range(1,len(jj)+1)
print(jj[['CAND_NAME','PARTY','AMOUNT']].head(100))
print('\nTOTAL = ' + '{:,}'.format(sum(jj['AMT'])))
                         CAND_NAME PARTY      AMOUNT
1                    RYAN, PAUL D.   REP  48,526,396
2                      JONES, DOUG   DEM  15,006,339
3                MCCASKILL, CLAIRE   DEM  12,757,572
4                   BROWN, SHERROD   DEM  12,275,426
5              OSSOFF, T. JONATHAN   DEM  11,017,533
6    GILLIBRAND, KIRSTEN ELIZABETH   DEM  10,837,981
7                  MCCARTHY, KEVIN   REP   9,928,647
8                   BALDWIN, TAMMY   DEM   8,245,775
9               CASEY, ROBERT P JR   DEM   7,162,817
10                    CORNYN, JOHN   REP   6,877,185
11                    NELSON, BILL   DEM   6,430,450
12         CRUZ, RAFAEL EDWARD TED   REP   6,043,705
13            WALL, KATHALEEN MRS.   REP   5,946,877
14         O'ROURKE, ROBERT (BETO)   DEM   5,370,099
15                STABENOW, DEBBIE   DEM   5,126,563
16                     FLAKE, JEFF   REP   4,952,431
17               SCALISE, STEVE MR   REP   4,622,876
18               WARREN, ELIZABETH   DEM   4,617,387
19          KAINE, TIMOTHY MICHAEL   DEM   4,589,416
20        MURPHY, CHRISTOPHER S MR   DEM   4,569,885
21                     TESTER, JON   DEM   4,399,408
22                 TRUMP, DONALD J   REP   4,119,461
23                 HEITKAMP, HEIDI   DEM   3,951,054
24                 CANTWELL, MARIA   DEM   3,878,647
25                    MANDEL, JOSH   REP   3,741,515
26                  HATCH, ORRIN G   REP   3,377,632
27                   PELOSI, NANCY   DEM   3,364,109
28         HANDEL, KAREN CHRISTINE   REP   3,332,693
29              DONNELLY, JOSEPH S   DEM   3,315,724
30                  KLOBUCHAR, AMY   DEM   3,125,576
31                MOORE, ROY JUDGE   REP   3,010,875
32                      MOODY, DAN   REP   2,957,283
33                 WICKER, ROGER F   REP   2,926,432
34                MENENDEZ, ROBERT   DEM   2,820,899
35                 GIANFORTE, GREG   REP   2,753,354
36         MCMORRIS RODGERS, CATHY   REP   2,749,751
37                    ROSEN, JACKY   DEM   2,694,142
38                     LAMB, CONOR   DEM   2,609,760
39                    HELLER, DEAN   REP   2,574,030
40           FLINN, GEORGE S DR JR   REP   2,545,300
41                    TRONE, DAVID   DEM   2,466,889
42               FEINSTEIN, DIANNE   DEM   2,452,617
43         KRISHNAMOORTHI, S. RAJA   DEM   2,447,871
44             CORKER, ROBERT P JR   REP   2,430,783
45                  COTTON, THOMAS   REP   2,292,258
46         HEINRICH, MARTIN TREVOR   DEM   2,291,637
47          WHITEHOUSE, SHELDON II   DEM   2,287,863
48                 SINEMA, KYRSTEN   DEM   2,249,007
49             WARNER, MARK ROBERT   DEM   2,237,445
50            AYYADUSAI, SHIVA  DR   REP   2,119,526
51                GOTTHEIMER, JOSH   DEM   2,112,670
52                    SCHIFF, ADAM   DEM   2,095,618
53                  BOOKER, CORY A   DEM   2,081,557
54                QUIST, ROBERT E.   DEM   2,037,947
55                BARRASSO, JOHN A   REP   1,976,212
56           BLACKBURN, MARSHA MRS   REP   1,946,495
57                 MCSALLY, MARTHA   REP   1,944,954
58                      KERR, PAUL   DEM   1,935,372
59                   ROYCE, ED MR.   REP   1,913,217
60                MANDEL, JOSHUA A   REP   1,869,336
61                   KHANNA, ROHIT   DEM   1,837,823
62          KING, ANGUS STANLEY JR   IND   1,784,714
63               GRAHAM, LINDSEY O   REP   1,781,067
64                   ERNST, JONI K   REP   1,780,339
65         ROKITA, THEODORE EDWARD   REP   1,737,997
66            HAWLEY, JOSHUA DAVID   REP   1,737,615
67           STRANGE, LUTHER J III   REP   1,716,619
68                 CROWLEY, JOSEPH   DEM   1,677,401
69                    BRADY, KEVIN   REP   1,659,438
70              CARDIN, BENJAMIN L   DEM   1,629,662
71                    JACOBS, SARA   DEM   1,613,973
72             MESSER, ALLEN LUCAS   REP   1,591,618
73                   WALTERS, MIMI   REP   1,567,503
74                MANCHIN III, JOE   DEM   1,531,076
75                MCCONNELL, MITCH   REP   1,496,823
76             CURBELO, CARLOS MR.   REP   1,439,408
77           CRIST, CHARLIE JOSEPH   DEM   1,433,185
78              KOH, DANIEL ARRIGG   DEM   1,425,720
79               BARTOS, JEFFREY A   REP   1,384,961
80          WALDEN, GREGORY P. MR.   REP   1,376,480
81                   ROSKAM, PETER   REP   1,371,910
82                FINCHER, STEPHEN   REP   1,367,902
83        SCHNEIDER, BRADLEY SCOTT   DEM   1,362,577
84                DELGADO, ANTONIO   DEM   1,352,665
85                     FRANKEN, AL   DEM   1,346,354
86             NUNES, DEVIN GERALD   REP   1,326,511
87                 HIRONO, MAZIE K   DEM   1,315,732
88                   PERDUE, DAVID   REP   1,311,282
89                 CARBAJAL, SALUD   DEM   1,280,765
90             KENNEDY, JOHN NEELY   REP   1,254,210
91              CASSIDY, WILLIAM M   REP   1,229,178
92              STIVERS, STEVE MR.   REP   1,215,265
93                     DUFFY, SEAN   REP   1,209,194
94                 AHN, ROBERT LEE   DEM   1,190,524
95           MALONEY, SEAN PATRICK   DEM   1,177,286
96           KENNEDY, JOSEPH P III   DEM   1,091,017
97            NORMAN, RALPH W. JR.   REP   1,089,306
98                     MAST, BRIAN   REP   1,085,581
99                     ROSSI, DINO   REP   1,070,146
100               FISCHER, DEBRA S   REP   1,069,440

TOTAL = 665,461,258

For a Specified Contributor, List All Contributions to Committees

First, list all contributions to committees connected to specific candidates. Then, list all contributions to committees not connected to specific candidates.

In [55]:
def getIndividual2Candidate(name, city, state):
    jj = ii[ii['NAME'].str.contains(name, na=False)]
    if pd.notnull(city): jj = jj[jj['CITY'].str.contains(city, na=False)]
    if pd.notnull(state): jj = jj[jj['STATE'].str.contains(state, na=False)]
    jj = jj[pd.notnull(jj['CAND_ID'])]
    jj['AMOUNT'] = jj['AMT'].apply(lambda x: '{:,}'.format(x))
    jj = jj.sort_values(by='DATE',ascending=True)
    jj.index = range(1,len(jj)+1)
    kk = jj[['NAME','DATE','AMOUNT','CITY','STATE','CAND_NAME','PARTY']]
    print(kk.head(100))
    print('\nSUBTOTAL = ' + '{:,}'.format(sum(jj['AMT'])))

def getIndividual2Committee(name, city, state):
    jj = ii[ii['NAME'].str.contains(name, na=False)]
    if pd.notnull(city): jj = jj[jj['CITY'].str.contains(city, na=False)]
    if pd.notnull(state): jj = jj[jj['STATE'].str.contains(state, na=False)]
    jj = jj[pd.isnull(jj['CAND_ID'])]
    jj['AMOUNT'] = jj['AMT'].apply(lambda x: '{:,}'.format(x))
    jj = jj.sort_values(by='DATE',ascending=True)
    jj.index = range(1,len(jj)+1)
    kk = jj[['NAME','DATE','AMOUNT','CITY','STATE','CMTE_NM']]
    print(kk.head(100))
    print('\nSUBTOTAL = ' + '{:,}'.format(sum(jj['AMT'])))

def getIndividual2All(name, city, state):
    getIndividual2Candidate(name, city, state)
    getIndividual2Committee(name, city, state)

#getIndividual2All('UIHLEIN, RICHARD')
getIndividual2All('KOCH,', None, 'KS')
                           NAME       DATE   AMOUNT     CITY STATE              CAND_NAME PARTY
1             KOCH, ELIZABETH B 2017-06-30    2,700  WICHITA    KS         HATCH, ORRIN G   REP
2             KOCH, ELIZABETH B 2017-06-30    2,700  WICHITA    KS         HATCH, ORRIN G   REP
3               KOCH, CHARLES G 2017-06-30    2,700  WICHITA    KS         HATCH, ORRIN G   REP
4               KOCH, CHARLES G 2017-06-30    2,700  WICHITA    KS         HATCH, ORRIN G   REP
5                   KOCH, JULIA 2017-07-17    2,700  WICHITA    KS          ZELDIN, LEE M   REP
6                   KOCH, JULIA 2017-07-17    2,300  WICHITA    KS          ZELDIN, LEE M   REP
7                   KOCH, DAVID 2017-07-19    2,700  WICHITA    KS          ZELDIN, LEE M   REP
8                   KOCH, DAVID 2017-07-19    2,300  WICHITA    KS          ZELDIN, LEE M   REP
9         KOCH, ELIZABETH BUZZI 2017-11-27    2,700  WICHITA    KS  BLACKBURN, MARSHA MRS   REP
10                KOCH, CHARLES 2017-11-27    2,700  WICHITA    KS  BLACKBURN, MARSHA MRS   REP
11         KOCH, CHARLES G. MR. 2017-11-29  247,700  WICHITA    KS          RYAN, PAUL D.   REP
12      KOCH, ELIZABETH B. MRS. 2017-11-29  247,700  WICHITA    KS          RYAN, PAUL D.   REP
13          KOCH, ELIZABETH MRS 2017-12-01    2,700  WICHITA    KS       BARRASSO, JOHN A   REP
14             KOCH, CHARLES MR 2017-12-01    2,700  WICHITA    KS       BARRASSO, JOHN A   REP
15             KOCH, CHARLES MR 2017-12-01    2,700  WICHITA    KS   MORRISEY, PATRICK MR   REP
16  KOCH, ELIZABETH BUZZI MS MS 2017-12-01    2,700  WICHITA    KS   MORRISEY, PATRICK MR   REP
17                KOCH, CHASE C 2017-12-29    2,700  WICHITA    KS  BLACKBURN, MARSHA MRS   REP
18          KOCH, JULIA F. MRS. 2018-03-07    2,700  WICHITA    KS     HILL, JAMES FRENCH   REP
19          KOCH, JULIA F. MRS. 2018-03-07    2,700  WICHITA    KS     HILL, JAMES FRENCH   REP

SUBTOTAL = 540,500
                    NAME       DATE   AMOUNT     CITY STATE                                            CMTE_NM
1            KOCH, CHASE 2017-02-27    5,000  WICHITA    KS  FERT PAC (THE POLITICAL ACTION COMMITTEE OF TH...
2             KOCH, ANNA 2017-03-02    5,000  WICHITA    KS  KOCH INDUSTRIES, INC. POLITICAL ACTION COMMITT...
3              KOCH, C C 2017-03-02    5,000  WICHITA    KS  KOCH INDUSTRIES, INC. POLITICAL ACTION COMMITT...
4          KOCH, CHARLES 2017-06-30    5,000  WICHITA    KS  KOCH INDUSTRIES, INC. POLITICAL ACTION COMMITT...
5     KOCH, ELIZABETH B. 2017-06-30    5,000  WICHITA    KS  KOCH INDUSTRIES, INC. POLITICAL ACTION COMMITT...
6     KOCH, ELIZABETH MS 2017-06-30   33,900  WICHITA    KS                                               NRSC
7        KOCH, CHARLES G 2017-06-30   33,900  WICHITA    KS                                               NRSC
8     KOCH, CHARLES G MR 2017-06-30  101,700  WICHITA    KS                                               NRSC
9     KOCH, CHARLES G MR 2017-06-30  101,700  WICHITA    KS                                               NRSC
10    KOCH, ELIZABETH MS 2017-06-30  101,700  WICHITA    KS                                               NRSC
11    KOCH, ELIZABETH MS 2017-06-30  101,700  WICHITA    KS                                               NRSC
12      KOCH, CHASE C MR 2017-12-29  101,700  WICHITA    KS                                               NRSC
13  KOCH, CHASE CHASE MR 2017-12-29   33,900  WICHITA    KS                                               NRSC
14    KOCH, C. CHASE MR. 2017-12-31  101,700  WICHITA    KS                                               NRCC
15    KOCH, C. CHASE MR. 2017-12-31  101,700  WICHITA    KS                                               NRCC
16    KOCH, C. CHASE MR. 2017-12-31   33,900  WICHITA    KS                                               NRCC

SUBTOTAL = 872,500

For a Specified Committee, List All Individual Contributions

In [56]:
def getIndividual2Committee1(cmte_nm):
    jj = ii[ii['CMTE_NM'].str.contains(cmte_nm, na=False)]
    jj['AMOUNT'] = jj['AMT'].apply(lambda x: '{:,}'.format(x))
    jj = jj.sort_values(by='DATE',ascending=True)
    jj.index = range(1,len(jj)+1)
    kk = jj[['NAME','DATE','AMOUNT','CITY','STATE','CMTE_NM']]
    print(kk.head(100))
    print('\nSUBTOTAL = ' + '{:,}'.format(sum(jj['AMT'])))

getIndividual2Committee1('CROSSROAD')
                                  NAME       DATE     AMOUNT        CITY STATE              CMTE_NM
1            MCCORMICK, RICHARD D. MR. 2017-08-15     25,000      DENVER    CO  AMERICAN CROSSROADS
2               FRALIN, W. HEYWOOD MR. 2017-12-18     25,000     ROANOKE    VA  AMERICAN CROSSROADS
3  AGC CONSTRUCTION ADVOCACY FUND INC. 2017-12-21     25,000   ARLINGTON    VA  AMERICAN CROSSROADS
4     HILLWOOD DEVELOPMENT COMPANY LLC 2017-12-21  1,000,000      DALLAS    TX  AMERICAN CROSSROADS
5                      REEDER, KENNETH 2018-12-07        500  CINCINNATI    OH  AMERICAN CROSSROADS

SUBTOTAL = 1,075,500
C:\Users\bdavi\Anaconda3\lib\site-packages\ipykernel_launcher.py:3: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  This is separate from the ipykernel package so we can avoid doing imports until

For a Specified Candidate, List All Individual Contributions

In [58]:
def getIndividual2Candidate1(cand_name):
    jj = ii[ii['CAND_NAME'].str.contains(cand_name, na=False)]
    jj['AMOUNT'] = jj['AMT'].apply(lambda x: '{:,}'.format(x))
    jj = jj.sort_values(by='DATE',ascending=True)
    jj.index = range(1,len(jj)+1)
    kk = jj[['NAME','DATE','AMOUNT','CITY','STATE','CAND_NAME','PARTY']]
    print(kk.head(100))
    print('\nSUBTOTAL = ' + '{:,}'.format(sum(jj['AMT'])))

getIndividual2Candidate1('TRUMP')
                       NAME       DATE  AMOUNT                  CITY STATE        CAND_NAME PARTY
1           IJAMES, KEVIN M 2016-11-09   1,000              SULLIVAN    MO  TRUMP, DONALD J   REP
2              MACRI, FRANK 2016-11-30     250          PHILADELPHIA    PA  TRUMP, DONALD J   REP
3              TAMAYO, DINO 2016-11-30      30        EAST NORTHPORT    NY  TRUMP, DONALD J   REP
4           WEAVER, WILLIAM 2016-12-03     500          INDIANAPOLIS    IN  TRUMP, DONALD J   REP
5            LEMOINE, TAMMY 2016-12-09     250              MAUREPAS    LA  TRUMP, DONALD J   REP
6             HART, PATRICK 2016-12-09     100  PALOS VERDES ESTATES    CA  TRUMP, DONALD J   REP
7            BUETTNER, MARK 2016-12-17      59             DAVENPORT    IA  TRUMP, DONALD J   REP
8             BOWEN, MARTHA 2016-12-20      35           CATONSVILLE    MD  TRUMP, DONALD J   REP
9    GRIFFITH, JOSEPH P MR. 2016-12-29   1,000            CHARLESTON    SC  TRUMP, DONALD J   REP
10            DE PILLO, SAL 2017-01-10   2,700             JOHNSBURG    IL  TRUMP, DONALD J   REP
11          NICHOLS, ROBERT 2017-01-10     250            WASHINGTON    DC  TRUMP, DONALD J   REP
12              HAIRE, JUDY 2017-01-10     250                SONOMA    CA  TRUMP, DONALD J   REP
13             MEYER, DONNA 2017-01-10     250            SCOTTSDALE    AZ  TRUMP, DONALD J   REP
14          JOHNSON, TRESHA 2017-01-10     250             CLEVELAND    TX  TRUMP, DONALD J   REP
15         CORNELIUS, KATHY 2017-01-10     100         ARROYO GRANDE    CA  TRUMP, DONALD J   REP
16            SEARCY, ALICE 2017-01-10     100             BECKVILLE    TX  TRUMP, DONALD J   REP
17          HAUSMAN JR, RON 2017-01-10     250                  OAHU    HI  TRUMP, DONALD J   REP
18           THOMPSON, ERIC 2017-01-10     250               MADISON    IN  TRUMP, DONALD J   REP
19           SAMUEL, JULIAN 2017-01-10      35               HOUSTON    TX  TRUMP, DONALD J   REP
20        DEPILLO, KIMBERLY 2017-01-10     300             JOHNSBURG    IL  TRUMP, DONALD J   REP
21         HEDDEN, SHERRELL 2017-01-10      35               ELLIJAY    GA  TRUMP, DONALD J   REP
22          SCHREER, JOSHUA 2017-01-10     250              CARLSBAD    CA  TRUMP, DONALD J   REP
23            SCHULTE, MARY 2017-01-10       3                DALLAS    TX  TRUMP, DONALD J   REP
24           MCJUNKIN, DIRK 2017-01-10       5           BAKERSFIELD    CA  TRUMP, DONALD J   REP
25          BABYAK, MICHAEL 2017-01-10       1            WASHINGTON    DC  TRUMP, DONALD J   REP
26         BENDORF, CLARICE 2017-01-10      79                AUSTIN    TX  TRUMP, DONALD J   REP
27        STANDIFIRD, JACOB 2017-01-10     250           NOLENSVILLE    TN  TRUMP, DONALD J   REP
28             BUFORD, GARY 2017-01-10     100           HUNTINGBURG    IN  TRUMP, DONALD J   REP
29           MCJUNKIN, DIRK 2017-01-10       5           BAKERSFIELD    CA  TRUMP, DONALD J   REP
30           ALDRICH, NANCY 2017-01-10     100            WOODBRIDGE    VA  TRUMP, DONALD J   REP
31           MCJUNKIN, DIRK 2017-01-10       5           BAKERSFIELD    CA  TRUMP, DONALD J   REP
32             COLVIN, GARY 2017-01-10      50            BLOOMFIELD    KY  TRUMP, DONALD J   REP
33         GEORGATOS, JERRY 2017-01-10      79               SEAFORD    NY  TRUMP, DONALD J   REP
34             NARANG, PAUL 2017-01-10      25               ANTIOCH    IL  TRUMP, DONALD J   REP
35             SIDOW, BORIS 2017-01-10     100               AUGUSTA    GA  TRUMP, DONALD J   REP
36            FARAH, ALLAIN 2017-01-10      50                 MIAMI    FL  TRUMP, DONALD J   REP
37         LACASSAGNE, LORI 2017-01-10     183               RALEIGH    NC  TRUMP, DONALD J   REP
38          BARNES, KRISTEN 2017-01-10      35        SALT LAKE CITY    UT  TRUMP, DONALD J   REP
39      PAKRADOONI, STEPHEN 2017-01-10      50                SEWELL    NJ  TRUMP, DONALD J   REP
40            TARVER, COREY 2017-01-10     160           LAKE CHARLE    LA  TRUMP, DONALD J   REP
41            MILLER, JOYCE 2017-01-10     146             CAMP HILL    PA  TRUMP, DONALD J   REP
42            LEVENDA, MARK 2017-01-20      34                  MESA    AZ  TRUMP, DONALD J   REP
43             MOORE, HENRY 2017-01-20    -250            SPRINGDALE    UT  TRUMP, DONALD J   REP
44             MOORE, HENRY 2017-01-20     250            SPRINGDALE    UT  TRUMP, DONALD J   REP
45           SEALES, JOSEPH 2017-01-20     250               OPELIKA    AL  TRUMP, DONALD J   REP
46           SEALES, JOSEPH 2017-01-20    -250               OPELIKA    AL  TRUMP, DONALD J   REP
47          ROBERTS, HAROLD 2017-01-20    -250             HENDERSON    NV  TRUMP, DONALD J   REP
48          ROBERTS, HAROLD 2017-01-20     250             HENDERSON    NV  TRUMP, DONALD J   REP
49           SEALES, JOSEPH 2017-01-20     250               OPELIKA    AL  TRUMP, DONALD J   REP
50              JORDE, JOHN 2017-01-20  -1,000            SCOTTSDALE    AZ  TRUMP, DONALD J   REP
51      EAMTRAKUL, DOUNGRAT 2017-01-20    -100              NEW YORK    NY  TRUMP, DONALD J   REP
52      EAMTRAKUL, DOUNGRAT 2017-01-20     100              NEW YORK    NY  TRUMP, DONALD J   REP
53           JONES, WILLIAM 2017-01-20     100                AUSTIN    TX  TRUMP, DONALD J   REP
54           JONES, WILLIAM 2017-01-20     100                AUSTIN    TX  TRUMP, DONALD J   REP
55           MADDOX, ALICIA 2017-01-20    -200                HOOVER    AL  TRUMP, DONALD J   REP
56           MADDOX, ALICIA 2017-01-20     200                HOOVER    AL  TRUMP, DONALD J   REP
57           JONES, WILLIAM 2017-01-20    -100                AUSTIN    TX  TRUMP, DONALD J   REP
58           SEALES, JOSEPH 2017-01-20    -250               OPELIKA    AL  TRUMP, DONALD J   REP
59             MOORE, HENRY 2017-01-20     250            SPRINGDALE    UT  TRUMP, DONALD J   REP
60             MOORE, HENRY 2017-01-20    -250            SPRINGDALE    UT  TRUMP, DONALD J   REP
61            MOORE, CURTIS 2017-01-20     100           VAN ALSTYNE    TX  TRUMP, DONALD J   REP
62             DYKES, DAVID 2017-01-20     280              DADVILLE    AL  TRUMP, DONALD J   REP
63     SACERIO-POLAK, ALINA 2017-01-20     250           WINTER PARK    FL  TRUMP, DONALD J   REP
64             TUBBS, DAVID 2017-01-20     -75                TOCCOA    GA  TRUMP, DONALD J   REP
65             DYKES, DAVID 2017-01-20    -280              DADVILLE    AL  TRUMP, DONALD J   REP
66          DVORSKY, JOAN M 2017-01-20      59                RACINE    WI  TRUMP, DONALD J   REP
67          DVORSKY, JOAN M 2017-01-20     -59                RACINE    WI  TRUMP, DONALD J   REP
68         DUVOISIN, RONALD 2017-01-20      74              METAIRIE    LA  TRUMP, DONALD J   REP
69         DUVOISIN, RONALD 2017-01-20     -74              METAIRIE    LA  TRUMP, DONALD J   REP
70             GRIMM, CAROL 2017-01-20    -202            WHITE LAKE    MI  TRUMP, DONALD J   REP
71           JONES, WILLIAM 2017-01-20    -100                AUSTIN    TX  TRUMP, DONALD J   REP
72             GRIMM, CAROL 2017-01-20     202            WHITE LAKE    MI  TRUMP, DONALD J   REP
73          HEILIG, MICHAEL 2017-01-20     250             LEXINGTON    KY  TRUMP, DONALD J   REP
74     SACERIO-POLAK, ALINA 2017-01-20    -250           WINTER PARK    FL  TRUMP, DONALD J   REP
75          HEILIG, MICHAEL 2017-01-20    -250             LEXINGTON    KY  TRUMP, DONALD J   REP
76          HEILIG, MICHAEL 2017-01-20     250             LEXINGTON    KY  TRUMP, DONALD J   REP
77           REDWINE, JASON 2017-01-20     100            CALIFORNIA    KY  TRUMP, DONALD J   REP
78           REDWINE, JASON 2017-01-20    -100            CALIFORNIA    KY  TRUMP, DONALD J   REP
79        HAUSCHILDT, DIANE 2017-01-20     250                  AZLE    TX  TRUMP, DONALD J   REP
80              MCKEE, GWEN 2017-01-20    -250               BRANDON    MS  TRUMP, DONALD J   REP
81              MCKEE, GWEN 2017-01-20     250               BRANDON    MS  TRUMP, DONALD J   REP
82          HEILIG, MICHAEL 2017-01-20    -250             LEXINGTON    KY  TRUMP, DONALD J   REP
83           ANZALONE, DREW 2017-01-20     -59              MARLBORO    NJ  TRUMP, DONALD J   REP
84           ANZALONE, DREW 2017-01-20      59              MARLBORO    NJ  TRUMP, DONALD J   REP
85            JONES, ROBERT 2017-01-20     250                DURAND    MI  TRUMP, DONALD J   REP
86   HATTAWAY, ROBERT T MR. 2017-01-20    -500     ALTAMONTE SPRINGS    FL  TRUMP, DONALD J   REP
87   HATTAWAY, ROBERT T MR. 2017-01-20     500     ALTAMONTE SPRINGS    FL  TRUMP, DONALD J   REP
88             HAUCK, SUSAN 2017-01-20     -74                  KATY    TX  TRUMP, DONALD J   REP
89        SHOWALTER, ROBERT 2017-01-20    -500            PLANT CITY    FL  TRUMP, DONALD J   REP
90        SHOWALTER, ROBERT 2017-01-20    -500            PLANT CITY    FL  TRUMP, DONALD J   REP
91        SHOWALTER, ROBERT 2017-01-20    -500            PLANT CITY    FL  TRUMP, DONALD J   REP
92           REYNOLDS, MARY 2017-01-20     340                 SALEM    NH  TRUMP, DONALD J   REP
93        SHOWALTER, ROBERT 2017-01-20    -500            PLANT CITY    FL  TRUMP, DONALD J   REP
94          SHROYER, DONALD 2017-01-20    -250             WIMBERLEY    TX  TRUMP, DONALD J   REP
95            BROWN, LIONEL 2017-01-20     250               NEWTOWN    CT  TRUMP, DONALD J   REP
96          SHROYER, DONALD 2017-01-20     250             WIMBERLEY    TX  TRUMP, DONALD J   REP
97            BROWN, LIONEL 2017-01-20    -250               NEWTOWN    CT  TRUMP, DONALD J   REP
98            BROWN, LIONEL 2017-01-20     250               NEWTOWN    CT  TRUMP, DONALD J   REP
99            BROWN, LIONEL 2017-01-20    -250               NEWTOWN    CT  TRUMP, DONALD J   REP
100    HESSLER, CHRISTOPHER 2017-01-20    -205            MORGANTOWN    PA  TRUMP, DONALD J   REP

SUBTOTAL = 4,119,461
C:\Users\bdavi\Anaconda3\lib\site-packages\ipykernel_launcher.py:3: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  This is separate from the ipykernel package so we can avoid doing imports until