Python 数据可视化神器—Pyecharts

本文介绍了如何在Python中使用Pyecharts库进行数据可视化,包括柱状图、饼状图、箱型图、折线图和雷达图的实现,展示了从Hive数据库查询数据到生成各种图表的过程。
摘要由CSDN通过智能技术生成

前言

Echarts 是百度开源的一款数据可视化 JS 工具,数据可视化类型十分丰富,但是得通过导入 js 库在 Java Web 项目上运行。

作为工作中常用 Python 的选手,不能不知道这款数据可视化插件的强大。那么,能否在 Python 中也能用到 Echarts 的功能呢?寻找中惊喜地发现了 pyecharts,只需在python中安装该模块即可使用。

安装

常用的pip安装包一键安装pyecharts

# pyecharts安装命令:
python -m pip install pyecharts

Python + pyecharts具体应用

结合工作中的项目数据,我选择了 test 项目需求中 hotel_code_new 为 CNSZVS_002,CWSWS_003 对应2019年12个月指标为 RNs 的数据做可视化展示与分析。

1.Hive数据库查询sql

hive_sql内容如下

# sql中所使用的部分语法为hive sql中常规的语法,与mysql有所不同,请注意。
select rrrd1.hotel_code_new as hotel_code_new
      ,dda.natural_date as natural_date
      ,nvl(rrrd.room_nights, 0) as room_nights
 from ( select distinct substr(natural_dt,1,7) as natural_date 
    from dws.dws_test_date_calendar
    where dt_year='2019'
        )dda
        left join 
         (select 'CNSZVS_002' hotel_code_new
            UNION all select  'CWSWS_003' hotel_code_new
      )rrrd1
        left join
         (select  hotel_code_new
                    ,substr(stay_date,1,7) as stay_date
                    ,sum(number_of_room_nights) as room_nights
                from dwm.dwm_test_resvs_rom_daily_df
                where dt='2021-10-24'
                and hotel_code_new in(CNSZVS_002', 'CWSWS_003')
                    and resv_status in('CHECKEDSSSIN','CHECKEDSSSOUT')
                    and substr(stay_date,0,4) = '2019' 
                    group by hotel_code_new,substr(stay_date,1,7)
        )rrrd 
        on dda.natural_date = rrrd.stay_date 
        and rrrd1.hotel_code_new=rrrd.hotel_code_new
        order by rrrd.hotel_code_new;

2.Pytho

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值