陌陌聊天数据分析 (一)

这篇具有很好参考价值的文章主要介绍了陌陌聊天数据分析 (一)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

陌陌聊天数据分析(一)

目标

  • 基于Hadoop和Hive实现聊天数据统计分析,构建聊天数据分析报表

需求

  • 统计今日总消息量
  • 统计今日每小时消息量,发送和接收用户数量
  • 统计今日各地区发送消息数据量
  • 统计今日发送消息和接收消息用户数
  • 统计今日发送消息最多的用户前几名
  • 统计今日接收消息最多的用户前几名
  • 统计发送人手机型号分布情况
  • 统计发送人设备系统分布情况

数据来源

  • 聊天业务系统导出2021/11/01一天24小时用户聊天数据,以TSV文本形式存储在文件中
    • 数据大小:两个文件共14万条数据
    • 列分隔符:\t

数据集及所需文件

  • 链接:https://pan.baidu.com/s/1ToTanDrFRhAVsFTb2uclFg
    提取码:rkun

🥇基于Hive数仓实现需求开发

⚽建库建表 加载数据

  • 建库建表
--创建数据库
create database db_msg;
--切换数据库
use db_msg;

--建表
create table db_msg.tb_msg_source(
  msg_time             string  comment "消息发送时间"
  , sender_name        string  comment "发送人昵称"
  , sender_account     string  comment "发送人账号"
  , sender_sex         string  comment "发送人性别"
  , sender_ip          string  comment "发送人IP"
  , sender_os          string  comment "发送人操作系统"
  , sender_phonetype   string  comment "发送人手机型号"
  , sender_network     string  comment "发送人网络类型"
  , sender_gps         string  comment "发送人GPS定位"
  , receiver_name      string  comment "接收人昵称"
  , receiver_ip        string  comment "接收人IP"
  , receiver_account   string  comment "接收人账号"
  , receiver_os        string  comment "接收人操作系统"
  , receiver_phonetype string  comment "接收人手机型号"
  , receiver_network   string  comment "接收人网络类型"
  , receiver_gps       string  comment "接收人GPS定位"
  , receiver_sex       string  comment "接收人性别"
  , msg_type           string  comment "消息类型"
  , distance           string  comment "双方距离"
  , message            string  comment "消息内容"
)
--指定分隔符为制表符
row format delimited fields terminated by '\t';

  • 加载数据
#上传数据到node1服务器本地文件系统(HS2服务所在机器)
[root@node1 hivedata]# pwd
/root/hivedata
[root@node1 hivedata]# ll
total 54104
-rw-r--r-- 1 root root 28237023 Jun 13 20:24 data1.tsv
-rw-r--r-- 1 root root 27161148 Jun 13 20:24 data2.tsv

--加载数据入表
load data local inpath '/root/hivedata/data1.tsv' into table db_msg.tb_msg_source;
load data local inpath '/root/hivedata/data2.tsv' into table db_msg.tb_msg_source;
  • 查询表,查看数据是否导入成功
--查询表
select * from tb_msg_source limit 5;

陌陌聊天数据分析 (一)

⚾ETL数据清洗

数据问题

  • 当前数据,一些数据字段为空,不是合法数据。
  • 需求需要统计每天每个小时消息量,但数据中没有天和小时字段,只有整体时间字段,不好处理。
  • 需求中,GPS对经纬度在同一字段,不好处理。

ETL需求

  • 对字段为空的不合法数据进行过滤
    • where过滤
  • 通过时间字段构建天和小时字段
    • substr函数
  • 从GPS经纬度提取经纬度
    • split函数
  • 将ETL以后的结果保存到一张新的Hive表中
    • create table …as select…
create table db_msg.tb_msg_etl as
select *,
       substr(msg_time, 0, 10)   as dayinfo,    --获取天
       substr(msg_time, 12, 2)   as hourinfo,   --获取小时
       split(sender_gps, ",")[0] as sender_lng, --经度
       split(sender_gps, ",")[1] as sender_lat  --纬度
from db_msg.tb_msg_source
--过滤字段为空数据
where length(sender_gps) > 0;
select
    msg_time,dayinfo,hourinfo,sender_gps,sender_lng,sender_lat
from db_msg.tb_msg_etl
limit 5;
--查询数据

陌陌聊天数据分析 (一)

🏀需求指标SQL

  • 解读需求
  • 确定待查询数据表 from
  • 分析维度 group by
  • 找出计算指标 聚合
  • 细节 过滤 排序
  1. 统计今日消息总量

    --需求:统计今日总消息量
    create table if not exists tb_rs_total_msg_cnt
    comment "今日消息总量"
    as
    select
      dayinfo,
      count(*) as total_msg_cnt
    from db_msg.tb_msg_etl
    group by dayinfo;
    
    --查询
    select * from tb_rs_total_msg_cnt ;
    
    +------------------------------+------------------------------------+
    | tb_rs_total_msg_cnt.dayinfo  | tb_rs_total_msg_cnt.total_msg_cnt  |
    +------------------------------+------------------------------------+
    | 2021-11-01                   | 139062                             |
    +------------------------------+------------------------------------+
    
    
  2. 统计今日每小时消息量,发送/接收用户数

    create table tb_rs_hour_msg_cnt
    comment "每小时消息量趋势"
    as
    select
        dayinfo,
        hourinfo,
        count(*) as total_msg_cnt,
        count(distinct sender_account) as sender_usr_cnt,
        count(distinct receiver_account)as receiver_usr_cnt
    from db_msg.tb_msg_etl
    group by dayinfo,hourinfo;
    
    select * from tb_rs_hour_msg_cnt limit 5;
    
    +-----------------------------+------------------------------+-----------------------------------+------------------------------------+--------------------------------------+
    | tb_rs_hour_msg_cnt.dayinfo  | tb_rs_hour_msg_cnt.hourinfo  | tb_rs_hour_msg_cnt.total_msg_cnt  | tb_rs_hour_msg_cnt.sender_usr_cnt  | tb_rs_hour_msg_cnt.receiver_usr_cnt  |
    +-----------------------------+------------------------------+-----------------------------------+------------------------------------+--------------------------------------+
    | 2021-11-01                  | 00                           | 4349                              | 3520                               | 3558                                 |
    | 2021-11-01                  | 01                           | 2892                              | 2524                               | 2537                                 |
    | 2021-11-01                  | 02                           | 882                               | 842                                | 838                                  |
    | 2021-11-01                  | 03                           | 471                               | 463                                | 460                                  |
    | 2021-11-01                  | 04                           | 206                               | 202                                | 205                                  |
    +-----------------------------+------------------------------+-----------------------------------+------------------------------------+--------------------------------------+
    
    
  3. 统计今日各地区发送消息数据量

    create table tb_rs_loc_cnt
    comment "今日各地区发送总消息量"
    as select
      dayinfo,
      sender_gps,
      cast(sender_lng as double) as longitude,
      cast(sender_lat as double) as latitude,
      count(*) as total_msg_cnt
    from tb_msg_etl
    group by dayinfo, sender_gps, sender_lng,sender_lat;
    
    
    select * from tb_rs_loc_cnt limit 5;
    
    
    +------------------------+---------------------------+--------------------------+-------------------------+------------------------------+
    | tb_rs_loc_cnt.dayinfo  | tb_rs_loc_cnt.sender_gps  | tb_rs_loc_cnt.longitude  | tb_rs_loc_cnt.latitude  | tb_rs_loc_cnt.total_msg_cnt  |
    +------------------------+---------------------------+--------------------------+-------------------------+------------------------------+
    | 2021-11-01             | 100.297355,24.206808      | 100.297355               | 24.206808               | 1397                         |
    | 2021-11-01             | 100.591712,24.004148      | 100.591712               | 24.004148               | 1406                         |
    | 2021-11-01             | 101.62196,36.782187       | 101.62196                | 36.782187               | 1439                         |
    | 2021-11-01             | 102.357852,23.801165      | 102.357852               | 23.801165               | 1399                         |
    | 2021-11-01             | 102.357852,25.682909      | 102.357852               | 25.682909               | 1431                         |
    +------------------------+---------------------------+--------------------------+-------------------------+------------------------------+
    
    
  4. 统计今日发送消息和接受消息用户数

    create table tb_rs_usr_cnt
    comment "今日发送消息人数、接受消息人数"
    as
    select
      dayinfo,
      count(distinct sender_account) as sender_usr_cnt,
      count(distinct receiver_account) as receiver_usr_cnt
    from db_msg.tb_msg_etl
    group by dayinfo;
    
    select * from tb_rs_usr_cnt ;
    
    +------------------------+-------------------------------+---------------------------------+
    | tb_rs_usr_cnt.dayinfo  | tb_rs_usr_cnt.sender_usr_cnt  | tb_rs_usr_cnt.receiver_usr_cnt  |
    +------------------------+-------------------------------+---------------------------------+
    | 2021-11-01             | 10008                         | 10005                           |
    +------------------------+-------------------------------+---------------------------------+
    
    
  5. 统计今日发送消息最多的Top10用户

    create table tb_rs_susr_top10
    comment "发送消息条数最多的Top10用户"
    as
    select
      dayinfo,
      sender_name as username,
      count(*) as sender_msg_cnt
    from db_msg.tb_msg_etl
    group by dayinfo,sender_name
    order by sender_msg_cnt desc
    limit 10;
    
    select * from tb_rs_susr_top10;
    
    +---------------------------+----------------------------+----------------------------------+
    | tb_rs_susr_top10.dayinfo  | tb_rs_susr_top10.username  | tb_rs_susr_top10.sender_msg_cnt  |
    +---------------------------+----------------------------+----------------------------------+
    | 2021-11-01                | 茹鸿晖                        | 1466                             |
    | 2021-11-01                | 卢高达                        | 1464                             |
    | 2021-11-01                | 犁彭祖                        | 1460                             |
    | 2021-11-01                | 沐范                         | 1459                             |
    | 2021-11-01                | 夫潍                         | 1452                             |
    | 2021-11-01                | 烟心思                        | 1449                             |
    | 2021-11-01                | 称子瑜                        | 1447                             |
    | 2021-11-01                | 麻宏放                        | 1442                             |
    | 2021-11-01                | 邴时                         | 1439                             |
    | 2021-11-01                | 养昆颉                        | 1431                             |
    +---------------------------+----------------------------+----------------------------------+
    
    
  6. 统计今日接受消息最多的Top10用户

    create table tb_rs_rusr_top10
    comment "接受消息条数最多的Top10用户"
    as
    select
      dayinfo,
      receiver_name as username,
      count(*) as receiver_msg_cnt
    from db_msg.tb_msg_etl
    group by dayinfo,receiver_name
    order by receiver_msg_cnt desc
    limit 10;
    
    select * from tb_rs_rusr_top10 limit 3;
    
    +---------------------------+----------------------------+------------------------------------+
    | tb_rs_rusr_top10.dayinfo  | tb_rs_rusr_top10.username  | tb_rs_rusr_top10.receiver_msg_cnt  |
    +---------------------------+----------------------------+------------------------------------+
    | 2021-11-01                | 畅雅柏                        | 1539                               |
    | 2021-11-01                | 春纯                         | 1491                               |
    | 2021-11-01                | 邝琨瑶                        | 1469                               |
    +---------------------------+----------------------------+------------------------------------+
    
    
  7. 统计发送人手机型号分布情况

    create table if not exists tb_rs_sender_phone
    comment "发送人的手机型号分布"
    as
    select
      dayinfo,
      sender_phonetype,
      count(distinct sender_account) as cnt
    from tb_msg_etl
    group by dayinfo,sender_phonetype;
    
    select * from tb_rs_sender_phone limit 3;
    
    +-----------------------------+--------------------------------------+-------------------------+
    | tb_rs_sender_phone.dayinfo  | tb_rs_sender_phone.sender_phonetype  | tb_rs_sender_phone.cnt  |
    +-----------------------------+--------------------------------------+-------------------------+
    | 2021-11-01                  | Apple iPhone 10                      | 6749                    |
    | 2021-11-01                  | Apple iPhone 11                      | 3441                    |
    | 2021-11-01                  | Apple iPhone 7                       | 2424                    |
    +-----------------------------+--------------------------------------+-------------------------+
    
    
  8. 统计发送人设备操作系统分布情况

    create table tb_rs_sender_os
    comment "发送人的OS分布"
    as
    select
      dayinfo,
      sender_os,
      count(distinct sender_account) as cnt
    from tb_msg_etl
    group by dayinfo,sender_os;
    
    select * from tb_rs_sender_os;
    
    +--------------------------+----------------------------+----------------------+
    | tb_rs_sender_os.dayinfo  | tb_rs_sender_os.sender_os  | tb_rs_sender_os.cnt  |
    +--------------------------+----------------------------+----------------------+
    | 2021-11-01               | Android 5.1                | 5750                 |
    | 2021-11-01               | Android 6                  | 8514                 |
    | 2021-11-01               | Android 6.0                | 9398                 |
    | 2021-11-01               | Android 7.0                | 9181                 |
    | 2021-11-01               | Android 8.0                | 8594                 |
    | 2021-11-01               | IOS 10.0                   | 1289                 |
    | 2021-11-01               | IOS 12.0                   | 8102                 |
    | 2021-11-01               | IOS 9.0                    | 8760                 |
    +--------------------------+----------------------------+----------------------+
    
    

🎖️FineBI实现可视化报表

官网

https://www.finebi.com/

🏐配置数据源及数据准备

官方文档

https://help.fanruan.com/finebi/doc-view-301.html

  • 使用FineBI连接Hive,读取Hive数据表,需要在FineBI中添加Hive驱动jar包

  • 将Hive驱动jar包放入FineBI的lib目录下

  • 找到提供文件的HiveConnectDrive

陌陌聊天数据分析 (一)

  • 放入安装路径下的 webapps\webroot\WEB-INF\lib

陌陌聊天数据分析 (一)

插件安装

  • 我们自己Hive驱动包会与FineBI自带驱动包冲突,导致FineBI无法识别我们自己的驱动
  • 安装FineBI官方提供驱动包隔离插件

隔离插件:fr-plugin-hive-driver-loader-3.0.zip

  • 安装插件

    陌陌聊天数据分析 (一)

  • 重启FineBI文章来源地址https://www.toymoban.com/news/detail-490053.html

到了这里,关于陌陌聊天数据分析 (一)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 基于Hadoop和Hive的聊天数据(FineBI)可视化分析

    目录 1. 准备工作 2. 新建数据库连接 3. 在Hive数据库中创建存放数据的表 4. ETL数据清洗 5. 指标 ​6. 进入Fine BI数据中心 参考内容https://www.bilibili.com/read/cv15490959/ 数据文件、jar包、插件 https://pan.baidu.com/s/1Mpquo0EgkyZtLHrCPIK2Qg?pwd=7w0k 在FineBI6.0webappswebrootWEB-INFlib下放置jar包 启动

    2024年04月17日
    浏览(69)
  • 【数据分析】:什么是数据分析?

    🌸个人主页:JoJo的数据分析历险记 📝个人介绍: 统计学top3 研究生 💌如果文章对你有帮助,欢迎✌ 关注 、👍 点赞 、✌ 收藏 、👍 订阅 专栏 ✨本文收录于【数据分析】本专栏介绍数据分析从入门到项目实战,包含 用户分析、留存分析、行业分析 等。本系列会坚持完成

    2024年02月11日
    浏览(34)
  • 数据分析_数据分析思维(1)

    这篇文章具体的给大家介绍数据分析中最为核心的技术之一: 数据分析思维的相关内容。 作为新手数据分析师或数据运营, 在面对数据异常的时候, 好多小伙伴都会出现: “好像是A引起的”, “好像也和B渠道有关”, “也可能是竞争对手 C 做了竞争动作” 等主观臆测。面对数据

    2024年04月26日
    浏览(24)
  • 数据分析:消费者数据分析

    作者:i阿极 作者简介:Python领域新星作者、多项比赛获奖者:博主个人首页 😊😊😊如果觉得文章不错或能帮助到你学习,可以点赞👍收藏📁评论📒+关注哦!👍👍👍 📜📜📜如果有小伙伴需要数据集和学习交流,文章下方有交流学习区!一起学习进步!💪 随着互联网

    2024年01月15日
    浏览(54)
  • 数据分析基础:数据可视化+数据分析报告

    数据分析是指通过对大量数据进行收集、整理、处理和分析,以发现其中的模式、趋势和关联,并从中提取有价值的信息和知识。 数据可视化和数据分析报告是数据分析过程中非常重要的两个环节,它们帮助将数据转化为易于理解和传达的形式,提供决策支持和洞察力。在接

    2024年02月07日
    浏览(41)
  • 【数据分析】:数据分析三大思路及方法

    在上一篇博文【什么是数据分析】中,我们介绍了数据分析的基本概念、流程、方法。这篇文章我们来看看数据分析的基本思路以及常见的数据分析方法。在互联网分析中,基本遵循以下三个步骤: 找出问题 分析问题 解决问题 接下来,我们来看看如何进行一个完整的数据分

    2023年04月09日
    浏览(66)
  • 【业务数据分析】——十大常用数据分析方法

    🤵‍♂️ 个人主页:@Lingxw_w的个人主页 ✍🏻作者简介:计算机科学与技术研究生在读 🐋 希望大家多多支持,我们一起进步!😄 如果文章对你有帮助的话, 欢迎评论 💬点赞👍🏻 收藏 📂加关注+  目录 一、数据分析方法 二、营销管理方法论 1、SWOT分析 2、PEST分析 3、

    2023年04月22日
    浏览(33)
  • 数据分析讲课笔记01:数据分析概述

    理解数据分析背景 :学生将能够阐述大数据时代对数据分析的影响,以及数据分析在商业决策、科研发现、产品优化等方面的重要作用。 掌握数据分析基本概念与分类 :学生应能清晰定义数据分析的概念,并能区分描述性数据分析(用于总结和解释数据集的特征)、探索性

    2024年02月01日
    浏览(44)
  • Python数据分析—基于机器学习的UCI心脏病数据分析(源码+数据+分析设计)

    下载链接:https://pan.baidu.com/s/1ys2F6ZH4EgnFdVP2mkTcsA?pwd=LCFZ 提取码:LCFZ 心脏病是一类比较常见的循环系统疾病。循环系统由心脏、血管和调节血液循环的神经体液组织构成,循环系统疾病也称为心血管病,包括上述所有组织器官的疾病,在内科疾病中属于常见病,其中以心脏病

    2024年02月07日
    浏览(38)
  • 浅析『链上数据分析』 : 区块链 + 数据分析

    什么是链上数据分析? 01 区块链 02 链上数据 03 为什么要分析链上数据 04 数据分析思维 05 数据分析技能 06 数据分析工具 07 业务逻辑理解 链上数据分析,顾名思义,就是对区块链上的数据进行分析。 其实就是将数据分析运用到区块链行业上,和其他的如电商数据分析一样,

    2023年04月08日
    浏览(27)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包