In [2]:
import pandas as pd
import numpy as np

In [3]:
donations = pd.read_csv('P00000001-ALL.csv', dtype='object')
donations['contb_receipt_amt'] = pd.to_numeric(donations['contb_receipt_amt'])

In [ ]:
donations.groupby("cand_nm").median().sort_values("contb_receipt_amt").plot(kind='bar')

In [ ]:
donations.dtypes

In [33]:
pdonations = donations[['contbr_st', 'cand_nm', 'contbr_occupation', 'contb_receipt_amt']]

In [43]:
pdonations.so


Out[43]:
contbr_st               int8
cand_nm                 int8
contbr_occupation      int32
contb_receipt_amt    float64
dtype: object

In [50]:
donations['contbr_nm'].describe()


Out[50]:
count     7344719
unique    1352948
top       ACTBLUE
freq        15244
Name: contbr_nm, dtype: object

In [51]:
ls


66cfcf6d3724405bb15b0099faa46142_0.csv      P00000001-ALL.zip  Trumpanzes.ipynb
66cfcf6d3724405bb15b0099faa46142_0.geojson  PDownload.do       Untitled.ipynb
data/                                       results/
P00000001-ALL.csv                           Test1.ipynb

In [56]:
donations.keys()
donations.values


Out[56]:
array([['C00458844', 'P60006723', 'Rubio, Marco', ..., 'SA17.1152124',
        'P2016', nan],
       ['C00458844', 'P60006723', 'Rubio, Marco', ..., 'SA17.1153048',
        'P2016', nan],
       ['C00458844', 'P60006723', 'Rubio, Marco', ..., 'SA17.1020839',
        'P2016', nan],
       ..., 
       ['C00623884', 'P60022654', 'McMullin, Evan', ..., 'SA17A.76793',
        nan, nan],
       ['C00623884', 'P60022654', 'McMullin, Evan', ..., 'SA17A.54329',
        nan, nan],
       ['C00623884', 'P60022654', 'McMullin, Evan', ..., 'SA17A.53707',
        nan, nan]], dtype=object)

In [57]:
d = donations

In [66]:
d.head(2).T


Out[66]:
0 1
cmte_id C00458844 C00458844
cand_id P60006723 P60006723
cand_nm Rubio, Marco Rubio, Marco
contbr_nm BLUM, MAUREEN DODSON, MARK B. MR.
contbr_city WASHINGTON ATLANTA
contbr_st 20 30
contbr_zip DC GA
contbr_employer STRATEGIC COALITIONS & INITIATIVES LL MORTGAGE CAPITAL ADVISORS
contbr_occupation OUTREACH DIRECTOR PRIVATE MORTGAGE BANKING
contb_receipt_amt 175 25
contb_receipt_dt 15-MAR-16 16-MAR-16
receipt_desc NaN NaN
memo_cd NaN NaN
memo_text NaN DEBT RETIREMENT
form_tp SA17A SA17A
file_num 1082559 1082559
tran_id SA17.1152124 SA17.1153048
election_tp P2016 P2016
eol NaN NaN

In [124]:
d.groupby('cand_nm').sum().sort()


/opt/conda/lib/python3.5/site-packages/ipykernel/__main__.py:1: FutureWarning: sort(....) is deprecated, use sort_index(.....)
  if __name__ == '__main__':
Out[124]:
contb_receipt_amt
cand_nm
Bush, Jeb 3.153619e+07
Carson, Benjamin S. 2.633433e+07
Christie, Christopher J. 7.859470e+06
Clinton, Hillary Rodham 5.157360e+08
Cruz, Rafael Edward 'Ted' 5.632231e+07
Fiorina, Carly 6.370927e+06
Gilmore, James S III 1.025097e+05
Graham, Lindsey O. 3.671464e+06
Huckabee, Mike 2.352096e+06
Jindal, Bobby 1.264593e+06
Johnson, Gary 3.557858e+06
Kasich, John R. 1.421977e+07
Lessig, Lawrence 6.214945e+05
McMullin, Evan 5.471783e+05
O'Malley, Martin Joseph 3.971291e+06
Pataki, George E. 5.046494e+05
Paul, Rand 6.058601e+06
Perry, James R. (Rick) 1.120363e+06
Rubio, Marco 3.130875e+07
Sanders, Bernard 9.224376e+07
Santorum, Richard J. 1.058824e+06
Stein, Jill 1.011175e+06
Trump, Donald J. 1.174192e+08
Walker, Scott 4.929504e+06
Webb, James Henry Jr. 4.392464e+05

In [125]:
2*2


Out[125]:
4

In [ ]: