#python# #数据分析# 性别比例分析


手头有一份性别比例的样本数据,清洗后只保留了性别信息,做了一个数据分析。

数据清洗和数据统计的代码就不贴了,贴性别比例pie图和性别比例趋势图的代码。

性别比例pie图:

def _plot_gender_stat_pie(self, fig, gender_stat, title):
    """
    fig : figure obj
    gender_stat : male / female stat
    title : figure title
    """
    def _explode(label, target='female'):
        if label == target:
            return 0.1
        else:
            return 0
    labels = ['male', 'female']
    expl = list(map(_explode, labels))
    plt.figure(fig, figsize=(7, 7))
    plt.pie(gender_stat, explode=expl, labels=labels, autopct="%5.2f%%")
    plt.title(title, bbox={'facecolor': '0.8', 'pad': 8})

平均性别比例:

年份比较图:





性别比例趋势图代码:

def _plot_gender_stat_line_bar(self, gender_stats):
    """
    gender_stat : male / female stats by year
    """        
    y = gender_stats
    x = range(0, len(y))

    plt.figure(figsize=(10, 6)) 
    # line plot
    plt.plot(x, y, 'r.:')
    # plot text on each point
    for point_x, point_y in zip(x, y):
        plt.text(point_x, point_y, str('%.1f' %
                                       point_y), horizontalalignment='center')
    # bar plot
    plt.bar(x, y, width=0.5, color='g')
    plt.xlabel('time')
    plt.ylabel('rate')
    plt.title('male / female rate change', y=0.9)
    plt.show()

 

  • 样本数据有限,仅用来学习,无其他含义。

  • 是不是效益好的时候,男女性别比例就会小一些,效益不好或者初创期男女性别比例就会大一些?

  • 后面的趋势跟二胎政策也有一定关系。

(↓ - 有些内容只在小龙家发,可关注同名“趣Python”号,谢谢 - ↓) 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值