当前位置: 首页 > news >正文

专业的盐城网站建设搜狗链接提交入口

专业的盐城网站建设,搜狗链接提交入口,公司网站可以不买域名吗,合肥网站建设公司 千鸟目录 Hive 复合数据定义方法 Hive 复合数据查询方法 hive 内置函数 上机练习 Hive 复合数据定义方法 Hive 复合数据查询方法 hive 内置函数 -- 查看系统自带的函数 show functions; -- 显示自带的函数的用法 desc function upper; -- 详细显示自带的函数的用法 desc …

目录

Hive 复合数据定义方法

Hive 复合数据查询方法

hive 内置函数

上机练习


Hive 复合数据定义方法

Hive 复合数据查询方法

hive 内置函数

-- 查看系统自带的函数
show functions;
-- 显示自带的函数的用法
desc function upper;
-- 详细显示自带的函数的用法
desc function extended upper;

上机练习

1 导入 user 数据 id name sex age address date lev s_info m_info a_info
2 使用三种复合数据类型 struct map array 存储 info 数据
python 清洗数据:
with open(r"D:\智云大数据\数据源
\user\user_info.txt",'r',encoding="utf-8") as f:
LineRead=f.readlines()
# print(LineRead)
for i in LineRead:
list1=[]
list_i=i.split('\t')
# print(list_i)
# 把字典的值复制加到每行的末尾
for j in eval(list_i[7]).values():
list1.append(j)
str1='|'.join(list1)
list_i[7]=str1
list_i.append(str1)
# print(list_i)
list_i[8]='|'.join(list_i[8].split(',')).strip('\n') #
把第九列转化成可以导入 struct 的形式
str_i=','.join(list_i) # 每行每个数据用逗号隔开
# print(str_i)
with open(r"D:\智云大数据
\user_info_disposal_new.txt",'a',encoding='utf-8') as h:
h.writelines(str_i+"\n")
h.close()
f.close()
hive 建表和导入数据:
drop table if exists user_info;
create table if not exists user_info
(
id int,
name string,
sex string,
age tinyint,
address string,
date_info string,
lev tinyint,
a_info array<string>,
m_info map<string,string>,
s_info
struct<systemtype:string,education:string,marriage_status:string,phon
ebrand:string>
)
row format delimited
fields terminated by ','
collection items terminated by '|'
MAP keys terminated by ':'
lines terminated by '\n'
load data local inpath '/root/user_info_disposal_new.txt'
into table user_info;
结果:(双击 object 能看见值)
3 指标计算
3.1 按月统计各个地区男女生人数
select date_format(date_info,'YYYY-MM'),address,sex,count(1) from
user_info
group by date_format(date_info,'YYYY-MM'),address,sex3.2 统计各地区的不同手机型号使用人数,并按照老中青(35 以下青年 男 65 岁
以下女 55 岁以下中年 男 65 岁以上女 55 岁以上老年)年龄 划分
地区 安卓使用人数{老 中 青} ios 使用人数{老 中 青}
with SystemtypeAndAge as
(
select
case when m_info["systemtype"]='android' then 'android'
when m_info["systemtype"]='ios' then 'ios'end as systemtype,
case when age<35 then '青年'
when sex='male' and age<65 or sex='female' and age<55 then '中年'
else '老年'
end as AgeBracket
from user_info
)
select systemtype,AgeBracket,count(1) from SystemtypeAndAge
group by systemtype,AgeBracket

3.2 统计各地区的不同手机型号使用人数,并按照老中青(35 以下青年 男 65 岁
以下女 55 岁以下中年 男 65 岁以上女 55 岁以上老年)年龄 划分
地区 安卓使用人数{老 中 青} ios 使用人数{老 中 青}
with SystemtypeAndAge as
(
select
case when m_info["systemtype"]='android' then 'android'
when m_info["systemtype"]='ios' then 'ios'end as systemtype,
case when age<35 then '青年'
when sex='male' and age<65 or sex='female' and age<55 then '中年'
else '老年'
end as AgeBracket
from user_info
)
select systemtype,AgeBracket,count(1) from SystemtypeAndAge
group by systemtype,AgeBracket

3.3 统计不同地区,不同学历,使用的手机品牌(去重)collect_list
地区 学历 手机品牌列表
select user_info.address,education
,collect_list(distinct m_info["phonebrand"])
from user_info
left join
(
select address,
case m_info["education"] when "bachelor" then 'bachelor'
when "doctor" then 'doctor'when "master" then 'master'
end as education
from user_info
) EducationInAddress on user_info.address=EducationInAddress.address
group by user_info.address,education

3.4 统计不同等级,各个手机品牌的使用人数(需要行转列)
等级 phonebrand_list
{iphone6:5 iphone7:5 .....mi:5 .....iphoneXS:2}
这题我不会,老师沉迷黑吗喽作业视频讲解都还没发......
第三阶段太吃自学能力了,hive语法基本要去网上找。
http://www.wangmingla.cn/news/79276.html

相关文章:

  • 武汉p2p网站制作公司公司软文代写
  • 外国s网站建设山东移动网站建设
  • 南昌做网站哪家公司比较好成都百度业务员电话
  • 关于政府网站建设的几点建议阿里大数据分析平台
  • 视频网页制作教程网站seo推广
  • 天津 网站优化互联网产品运营
  • 做团餐 承包食堂的企业网站南京网站制作设计
  • 网站建设有模板吗韩国vs加纳分析比分
  • 珠海网站建设有限公司厦门网络关键词排名
  • 株洲网页seo包括哪些方面
  • 网站建设方案策划书ppt模板下载优化关键词的作用
  • 制作网站公司 可以要求后续修改吗松原头条新闻今日新闻最新
  • 早期做网站 如何推广百度手机版
  • c java 网站开发百度指数是免费的吗
  • 怎么做装修网站平台太原做网站的
  • 做书网站 时光体验营销是什么
  • 赣州大余做网站建设seo 优化教程
  • 凡科做网站真的免费吗百度关键字优化精灵
  • 中国制造网简介惠州seo外包公司
  • 公司网页网站建设百度小说搜索风云排行榜
  • 陕西省交通建设集团公司招聘网站泉州seo技术
  • 网站优化主要怎么做谷歌外贸平台推广需要多少钱
  • 政府网站建设依循的原则seo关键词优化工具
  • 谁家做网站比较好软文推广渠道
  • 服务器安装完面板怎么做网站今日头条新闻最新消息
  • wordpress oss 插件商丘seo教程
  • 桂林做手机网站网站制作公司有哪些
  • 临沂河东建设局网站百度免费
  • 上海移动云网站建设晋江怎么交换友情链接
  • 重庆做网站 帮助中心我要学电脑哪里有短期培训班