• Pandas+Pyecharts | 2022年世界500强数据分析可视化


    大家好,我是 👉【Python当打之年(点击跳转)】

    本期我们利用Python分析2022年世界500强企业信息数据,看看:

    • 500强企业大概分布在哪些国家
    • 500强企业中国企业有哪些,在国内各城市分布情况
    • 500强企业利润盈亏情况

    希望对小伙伴们有所帮助,如有疑问或者需要改进的地方可以私信小编。

    涉及到的库:

    • Pandas — 数据处理
    • Pyecharts — 数据可视化

    可视化部分:

    • 象形图 — PictorialBar
    • 柱状图 — Bar
    • 地图 — Map
    • 地理坐标系 — Geo
    • 水球图 — Liquid
    • 极坐标图 — Polar
    • 词云 — WordCloud

    🏳️‍🌈 1. 导入模块

    import pandas as pd
    from pyecharts.charts import Pie
    from pyecharts.charts import Bar
    from pyecharts.charts import Grid
    from pyecharts.charts import Map
    from pyecharts.charts import Geo
    from pyecharts.charts import WordCloud
    from pyecharts.charts import PictorialBar
    from pyecharts.charts import Liquid
    from pyecharts.charts import Polar
    from pyecharts import options as opts
    from pyecharts.commons.utils import JsCode
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    🏳️‍🌈 2.Pandas数据处理

    2.1 读取数据

    df = pd.read_excel('2022年世界五百强排行榜.xlsx')
    df.head(10)
    
    • 1
    • 2

    在这里插入图片描述

    2.2 查看数据信息

    df.info()
    
    • 1

    在这里插入图片描述

    • 500条数据没有确缺失,不需要进行其他处理。

    🏳️‍🌈 3. Pyecharts数据可视化

    3.1 各国世界500强企业数量排名柱状图

    bar = (
        Bar(init_opts=opts.InitOpts(width='1000px', height='1000px',bg_color='#0d0735'))
        .add_xaxis(x_data)
        .add_yaxis("",y_data)
        .set_series_opts(label_opts=opts.LabelOpts(position="right",
                                                  font_size=12,
                                                  font_weight='bold',
                                                  formatter='{c} 家'),
                        )
        .set_global_opts(
                        xaxis_opts=opts.AxisOpts(is_show=False,),
                        yaxis_opts=opts.AxisOpts(
                            axislabel_opts=opts.LabelOpts(font_size=13,color='#fff200'),
                            axistick_opts=opts.AxisTickOpts(is_show=False),
                            axisline_opts=opts.AxisLineOpts(is_show=False)
                        ),
                        title_opts=opts.TitleOpts(title="各国世界500强企业数量排名",pos_left='center',pos_top='1%',
                                  title_textstyle_opts=opts.TextStyleOpts(font_size=22,color="#38d9a9")),
                        visualmap_opts=opts.VisualMapOpts(is_show=False,
                                          min_=20,
                                          max_=150,
                                          is_piecewise=False,
                                          dimension=0,
                                          range_color=['#203fb6', '#008afb', '#ffec4a', '#ff6611', '#f62336']
                                                         ),
                        )
        .reversal_axis()
    )
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28

    在这里插入图片描述

    • 我国以145家世界500强企业高居榜首
    • 美国128家、日本47家位居二、三位
    • 亚洲方面还有韩国以18家的数量排名第六

    3.2 各国世界500强企业数量排名TOP8极坐标图

    p = (
        Polar(init_opts=opts.InitOpts(width='1000px', height='800px', bg_color='#0d0735'))
        .add_schema(
            radiusaxis_opts=opts.RadiusAxisOpts(data=x_data[-8:],
                                                type_='category'),
            angleaxis_opts=opts.AngleAxisOpts(
                  is_clockwise=True,
                  is_scale=True,
                  max_=150,
                  axislabel_opts=opts.LabelOpts(font_size=14, color='#fff200'),
                  axisline_opts=opts.AxisLineOpts(is_show=True,linestyle_opts=opts.LineStyleOpts(
                                                        width=2,type_='dashed',color='#e4e932')),
                  splitline_opts=opts.SplitLineOpts(is_show=True,
                        linestyle_opts=opts.LineStyleOpts(type_='dashed', color='#9FC131')
                    ),
                 ),
        )
        .add('',y_data[-8:], type_='bar')
        .set_global_opts(
            title_opts=opts.TitleOpts(title='各国世界500强企业数量排名TOP8',subtitle='制图@公众号:Python当打之年',pos_left='center',pos_top='1%',
                title_textstyle_opts=opts.TextStyleOpts(color='#38d9a9',font_size=20)
            ),
             visualmap_opts=opts.VisualMapOpts(max_=150, is_show = False, is_piecewise=True, split_number = 8, min_ = 10,
                                               range_color=['#203fb6', '#008afb', '#ffec4a', '#ff6611', '#f62336']
                                              ),
        )
    )
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    在这里插入图片描述

    3.3 各国世界500强企业数量占比饼状图

    在这里插入图片描述

    • 我国世界500强企业有145家,占比高达29%,接近总量的1/3

    • 美国占比24.8,日本占比9.4%

    3.4 各国世界500强企业数量排名TOP8象形图

    在这里插入图片描述

    3.5 中国各城市世界500强企业数量排名柱状图

    在这里插入图片描述

    国内方面:

    • 我国145家世界500强企业基本上也以一线城市居多
    • 北京以54家500强企业排名第一位,上海和深圳分别以12家和10家紧随其后
    • 北上广深中,广州以4家的数量跌出前5,排名第7

    3.6 各国世界500强企业数量地图分布

    m1 = (
        Map(init_opts=opts.InitOpts(width='1000px', height='500px',theme='dark',bg_color='#0d0735'))
        .add('公司数量',
             region_data,
             "world",
             is_map_symbol_show=False,
             is_roam=False,
            )
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(
            legend_opts=opts.LegendOpts(is_show=False),
            visualmap_opts=opts.VisualMapOpts(is_show=True,
                                              max_=150,
                                              min_=0,
                                              is_piecewise=True,
                                              split_number=10,
                                              pos_top='50%',
                                              pos_left='10%',
                                              range_color=['#9ecae1','#6baed6','#4292c6','#2171b5','#08519c','#08306b','#d4b9da','#c994c7','#df65b0','#e7298a','#ce1256','#980043','#67001f']
            ),
        )
    )
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    在这里插入图片描述

    3.7 中国世界500强企业数量占比水球图

    在这里插入图片描述

    3.8 世界500强企业公司名称词云

    wd = WordCloud(init_opts=opts.InitOpts(width='1000px',height='600px',theme='dark',bg_color='#0d0735'))
    wd.add('',
           [list(z) for z in zip(x_data, y_data)],
          )
    wd.set_global_opts(
            title_opts=opts.TitleOpts(
                title=""),
            tooltip_opts=opts.TooltipOpts(is_show=True),
        )
    wd.render_notebook()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    在这里插入图片描述

    营收方面:

    • 沃尔玛以572754百万美元的营业收入排名第1,亚马逊以469822百万美元的营业收入排名第2,我国国家电网有限公司以460616.9百万美元排名第3
    • 我国共有4家企业进入世界500强榜单前10:国家电网有限公司(3)、中国石油天然气集团有限公司(4)、中国石油化工集团有限公司(5)、中国建筑集团有限公司(9)

    🏳️‍🌈 4. 可视化项目源码+数据:

    网盘: https://pan.baidu.com/doc/share/Olj4d~aKuXT7AF0cq01MrQ-437060019167360
    提取码: pyra


    以上就是本期为大家整理的全部内容了,赶快练习起来吧,原创不易,喜欢的朋友可以点赞、收藏也可以分享注明出处)让更多人知道。

  • 相关阅读:
    飞行动力学 - 第31节-荷兰滚模态机理 之 基础点摘要
    muduo源码剖析之SocketOps类
    若依(ruoyi)之thymeleaf与jsp共存解决方案
    Neo4j图形数据库查询,Cypher语言详解
    (五) MdbCluster分布式内存数据库——数据迁移架构及节点扩缩容状态图
    Linux ARM平台开发系列讲解(IPCF异核通信) 2.11.3 IPCF异核通信驱动编译及其测试
    手写useState与useEffect
    jsp旅行网系统Myeclipse开发mysql数据库web结构java编程计算机网页项目
    react18 通过redux 做一个简单的状态管理基站
    单页应用(SPA)和多页应用(MPA)的区别和优缺点?
  • 原文地址:https://blog.csdn.net/weixin_42152811/article/details/126778147