물론 지금 살펴본 분석은 좀 더 개량할 수 있다. 예를 들어 기부자의 이름과 우편번호를 이용해
서 적은 금액을 자주 기부한 사람과 큰 금액을 기부한 사람별로 데이터를 집계할 수도 있을 것
이다. 나는 독자들이 이 데이터를 내려받아 직접 살펴보기 강력하게 권장한다.
14.5.3
주별 기부 통계
데이터를 후보자와 주별로 집계하는 것은 흔한 일이다.
In
[
220
]:
grouped
=
fec
_
mrbo
.
groupby
(['
cand
_
nm
',
'
contbr
_
st
'])
In
[
221
]:
totals
=
grouped
.
contb
_
receipt
_
amt
.
sum
().
unstack
(
0
).
fillna
(
0
)
In
[
222
]:
totals
=
totals
[
totals
.
sum
(
1
)
>
100000
]
In
[
223
]:
totals
[:
10
]
Out
[
223
]:
cand
_
nm Obama
,
Barack Romney
,
Mitt
contbr
_
st
AK 281840
.
15 86204
.
24
AL 543123
.
48 527303
.
51
AR 359247
.
28 105556
.
00
AZ 1506476
.
98 1888436
.
23
CA 23824984
.
24 11237636
.
60
CO 2132429
.
49 1506714
.
12
CT 2068291
.
26 3499475
.
45
DC 4373538
.
80 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.