pandas - 案例(美国2012年总统候选人政治献金数据分析)

# 提供数据

months = {'JAN' : 1, 'FEB' : 2, 'MAR' : 3, 'APR' : 4, 'MAY' : 5, 'JUN' : 6,
          'JUL' : 7, 'AUG' : 8, 'SEP' : 9, 'OCT': 10, 'NOV': 11, 'DEC' : 12}
parties = {
  'Bachmann, Michelle': 'Republican',
  'Romney, Mitt': 'Republican',
  'Obama, Barack': 'Democrat',
  "Roemer, Charles E. 'Buddy' III": 'Reform',
  'Pawlenty, Timothy': 'Republican',
  'Johnson, Gary Earl': 'Libertarian',
  'Paul, Ron': 'Republican',
  'Santorum, Rick': 'Republican',
  'Cain, Herman': 'Republican',
  'Gingrich, Newt': 'Republican',
  'McCotter, Thaddeus G': 'Republican',
  'Huntsman, Jon': 'Republican',
  'Perry, Rick': 'Republican'           
 }

 

导包:

# 导包

import numpy as np
import pandas as pd
from pandas import Series, DataFrame

1. 

 

2. 

 

 3. 

 

 4. 

 

5. 

 

 6. 

 

 7.

 

8. 

 

 9. 

 

posted @ 2019-05-14 16:44  孔辉  阅读(318)  评论(0编辑  收藏  举报