1.按州总捐款热力地图
按州总捐款热力地图
参赛选手自由发挥、补充
第一个补充热力地图的参赛选手可以获得天池杯子一个
import seaborn as sns
state_contribution=c_itcont.groupby('STATE').sum().sort_values("TRANSACTION_AMT", ascending=False)
all_contribution=state_contribution['TRANSACTION_AMT'].sum()
state_contribution['TRANSACTION_AMT']=state_contribution.TRANSACTION_AMT/all_contribution
sns.heatmap(state_contribution,cmap="YlGnBu")
2.收到捐赠额最多的两位候选人的总捐赠额变化趋势
收到捐赠额最多的两位候选人的总捐赠额变化趋势
参赛选手自由发挥、补充
第一个补充捐赠额变化趋势图的参赛选手可以获得天池杯子一个
first = c_itcont.groupby("CAND_NAME").sum().sort_values("TRANSACTION_AMT",ascending=False).index[0]
second = c_itcont.groupby("CAND_NAME").sum().sort_values("TRANSACTION_AMT",ascending=False).index[1]
x = list(c_itcont[c_itcont['CAND_NAME'] == first].groupby("TRANSACTION_DT")['TRANSACTION_AMT'].sum().index)
y1 = list(c_itcont[c_itcont['CAND_NAME'] == first].groupby("TRANSACTION_DT")['TRANSACTION_AMT'].sum())
y2 = list(c_itcont[c_itcont['CAND_NAME'] == second].groupby("TRANSACTION_DT")['TRANSACTION_AMT'].sum())
fig = plt.figure(figsize=(15, 8), dpi=80)
plt.xticks(rotation=40)
plt.xlabel('date')
plt.ylabel('money')
plt.plot(x, y1, label=first, color='red')
plt.plot(x, y2, label=second, color='blue')
plt.legend(loc='upper left')
plt.grid(alpha=0.2)
plt.title('Recruitment of two major candidates')
|