事故指标统计

[root@master ~]# hive

Logging initialized using configuration in jar:file:/usr/local/soft/hive-1.2.1/lib/hive-common-1.2.1.jar!/hive-log4j.properties
hive> select sgfssj from dwd.base_acd_file order by sgfssj limit 10;
2006-01-22 09:30:00.0
2006-12-21 00:15:00.0
2006-12-21 13:50:00.0
2006-12-21 16:30:00.0
2006-12-21 18:02:00.0
2006-12-22 11:30:00.0
2006-12-22 13:30:00.0
2006-12-22 14:30:00.0
2006-12-22 17:30:00.0
2006-12-22 23:55:00.0
Time taken: 28.559 seconds, Fetched: 10 row(s)
hive> select sgfssj from dwd.base_acd_file order by sgfssj desc limit 10;
OK
2020-10-14 17:28:00.0
2020-10-14 11:16:00.0
2020-10-13 23:06:00.0
2020-10-13 19:25:00.0
2020-10-13 14:12:00.0
2020-10-13 12:10:00.0
2020-10-12 16:04:00.0
2020-10-12 11:50:00.0
2020-10-12 07:38:00.0
2020-10-12 07:30:00.0
Time taken: 21.673 seconds, Fetched: 10 row(s)
hive> select current_date;
OK
2022-07-05
Time taken: 0.459 seconds, Fetched: 1 row(s)
hive> select year(sgfssj),count(*) from dwd.base_acd_file group by year(sgfssj);
2006	43
2007	1082
2008	1070
2009	1377
2010	1579
2011	2604
2012	2117
2013	1802
2014	1936
2015	1991
2016	2094
2017	1933
2018	2373
2019	2617
2020	1930
Time taken: 22.075 seconds, Fetched: 15 row(s)
hive> select substr(sgfssj,1,10)
    >         ,count(1)as dr_sgs
    > from dwd.base_acd_file 
    > group by substr(sgfssj,1,10);
Time taken: 45.99 seconds, Fetched: 4966 row(s)
hive> select t1.tjrq
    >         ,t1.dr_sgs
    >         ,sum(t1.dr_sgs)over (partition by substr(t1.tjrq,1,4))as jn_sgs
    > from(
    >     select substr(sgfssj,1,10)as tjrq
    >         ,count(1)as dr_sgs
    >     from dwd.base_acd_file 
    >     group by substr(sgfssj,1,10)
    > )t1;
Time taken: 45.99 seconds, Fetched: 4966 row(s)
hive> select t1.tjrq
    >         ,t1.dr_sgs
    >         ,sum(t1.dr_sgs)over (partition by substr(t1.tjrq,1,4))as jn_sgs
    >         ,lag(t1.dr_sgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_sgs
    > from(
    >     select substr(sgfssj,1,10)as tjrq
    >         ,count(1)as dr_sgs
    >     from dwd.base_acd_file 
    >     group by substr(sgfssj,1,10)
    > )t1;
Time taken: 73.903 seconds, Fetched: 4966 row(s)
hive> exit;
[root@master ~]# cd /usr/local/soft/spark-2.4.5/
[root@master spark-2.4.5]# ls
bin   examples    LICENSE   NOTICE  README.md  yarn
conf  jars        licenses  python  RELEASE
data  kubernetes  logs      R       sbin
[root@master spark-2.4.5]# spark-sql --conf spark.sql.shuffle.partitions=2
spark-sql> show databases;
22/07/05 11:11:24 INFO codegen.CodeGenerator: Code generated in 227.508135 ms
default
dwd
Time taken: 0.351 seconds, Fetched 2 row(s)
22/07/05 11:11:24 INFO thriftserver.SparkSQLCLIDriver: Time taken: 0.351 seconds, Fetched 2 row(s)
spark-sql> use dwd;
Time taken: 0.041 seconds
22/07/05 11:11:31 INFO thriftserver.SparkSQLCLIDriver: Time taken: 0.041 seconds
spark-sql> show tables;
22/07/05 11:11:41 INFO spark.ContextCleaner: Cleaned accumulator 2
22/07/05 11:11:41 INFO spark.ContextCleaner: Cleaned accumulator 0
22/07/05 11:11:41 INFO spark.ContextCleaner: Cleaned accumulator 1
22/07/05 11:11:41 INFO codegen.CodeGenerator: Code generated in 13.604985 ms
dwd	base_acd_file	false
dwd	base_acd_filehuman	false
dwd	base_bd_drivinglicense	false
dwd	base_bd_vehicle	false
dwd	base_vio_force	false
dwd	base_vio_surveil	false
dwd	base_vio_violation	false
Time taken: 0.119 seconds, Fetched 7 row(s)
22/07/05 11:11:41 INFO thriftserver.SparkSQLCLIDriver: Time taken: 0.119 seconds, Fetched 7 row(s)
spark-sql> select tt1.tjrq
         >         ,tt1.dr_sgs
         >         ,tt1.jn_sgs
         >         ,tt1.qntq_sgs
         >         ,NVL(round((abs(tt1.dr_sgs-tt1.qntq_sgs)/NVL(tt1.qntq_sgs,1))*100,2),0) as tb_sgs
         >         ,if(tt1.dr_sgs-tt1.qntq_sgs>0,"上升",'下降') as tb_sgs_bj
         > from(
         >     select t1.tjrq
         >         ,t1.dr_sgs
         >         ,sum(t1.dr_sgs)over (partition by substr(t1.tjrq,1,4))as jn_sgs
         >         ,lag(t1.dr_sgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_sgs
         >     from(
         >         select substr(sgfssj,1,10)as tjrq
         >             ,count(1)as dr_sgs
         >         from dwd.base_acd_file 
         >         group by substr(sgfssj,1,10)
         > )t1
         > )tt1;
Time taken: 0.596 seconds, Fetched 4966 row(s)
22/07/05 11:32:08 INFO thriftserver.SparkSQLCLIDriver: Time taken: 0.596 seconds, Fetched 4966 row(s)
spark-sql> select tt1.tjrq
         >         ,tt1.dr_sgs
         >         ,tt1.jn_sgs
         >         ,tt1.qntq_sgs
         >         ,NVL(round((abs(tt1.dr_sgs-tt1.qntq_sgs)/NVL(tt1.qntq_sgs,1))*100,2),0) as tb_sgs
         >         ,if(tt1.dr_sgs-tt1.qntq_sgs>0,"上升",'下降') as tb_sgs_bj
         > from(
         >     select t1.tjrq
         >         ,t1.dr_sgs
         >         ,sum(t1.dr_sgs)over (partition by substr(t1.tjrq,1,4))as jn_sgs
         >         ,lag(t1.dr_sgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_sgs
         >     from(
         >         select substr(sgfssj,1,10)as tjrq
         >             ,count(1)as dr_sgs
         >         from dwd.base_acd_file 
         >         group by substr(sgfssj,1,10)
         > )t1
         > )tt1
         > order by tt1.tjrq;
Time taken: 5.46 seconds, Fetched 4966 row(s)
22/07/05 14:36:35 INFO thriftserver.SparkSQLCLIDriver: Time taken: 5.46 seconds, Fetched 4966 row(s)
spark-sql> select tt1.tjrq
         >         ,tt1.dr_sgs
         >         ,tt1.jn_sgs
         >         ,tt1.qntq_sgs
         > 
         >         ,NVL(round((abs(tt1.dr_sgs-tt1.qntq_sgs)/NVL(tt1.qntq_sgs,1))*100,2),0) as tb_sgs
         >         ,if(tt1.dr_sgs-tt1.qntq_sgs>0,"上升",'下降') as tb_sgs_bj
         > 
         >         ,NVL(round((abs(tt1.dr_swsgs-tt1.qntq_swsgs)/NVL(tt1.qntq_swsgs,1))*100,2),0) as tb_swsgs
         >         ,if(tt1.dr_swsgs-tt1.qntq_swsgs>0,"上升",'下降') as tb_swsgs_bj
         > from(
         >     select t1.tjrq
         >         ,t1.dr_sgs
         >         ,t1.dr_swsgs
         > 
         >         ,sum(t1.dr_sgs)over (partition by substr(t1.tjrq,1,4))as jn_sgs
         >         ,lag(t1.dr_sgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_sgs
         > 
         >         ,sum(t1.dr_swsgs)over (partition by substr(t1.tjrq,1,4))as jn_swsgs
         >         ,lag(t1.dr_swsgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_swsgs
         >     from(
         >         select substr(sgfssj,1,10)as tjrq
         >             ,count(1)as dr_sgs
         >             ,sum(if(swrs7>0,1,0))as dr_swsgs
         >         from dwd.base_acd_file 
         >         group by substr(sgfssj,1,10)
         > )t1
         > )tt1
         > order by tt1.tjrq;
Time taken: 5.372 seconds, Fetched 4966 row(s)
22/07/05 15:17:19 INFO thriftserver.SparkSQLCLIDriver: Time taken: 5.372 seconds, Fetched 4966 row(s)
spark-sql> select tt1.tjrq
         >         ,tt1.dr_sgs
         >         ,tt1.jn_sgs
         >         ,tt1.qntq_sgs
         >         ,tt1.dr_swsgs
         >         ,tt1.qntq_swsgs
         > 
         >         ,NVL(round((abs(tt1.dr_sgs-tt1.qntq_sgs)/NVL(tt1.qntq_sgs,1))*100,2),0) as tb_sgs
         >         ,if(tt1.dr_sgs-tt1.qntq_sgs>0,"上升",'下降') as tb_sgs_bj
         > 
         >         ,NVL(round((abs(tt1.dr_swsgs-tt1.qntq_swsgs)/NVL(tt1.qntq_swsgs,1))*100,2),0) as tb_swsgs
         >         ,if(tt1.dr_swsgs-tt1.qntq_swsgs>0,"上升",'下降') as tb_swsgs_bj
         > from(
         >     select t1.tjrq
         >         ,t1.dr_sgs
         >         ,t1.dr_swsgs
         > 
         >         ,sum(t1.dr_sgs)over (partition by substr(t1.tjrq,1,4))as jn_sgs
         >         ,lag(t1.dr_sgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_sgs
         > 
         >         ,sum(t1.dr_swsgs)over (partition by substr(t1.tjrq,1,4))as jn_swsgs
         >         ,lag(t1.dr_swsgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_swsgs
         >     from(
         >         select substr(sgfssj,1,10)as tjrq
         >             ,count(1)as dr_sgs
         >             ,sum(if(swrs7>0,1,0))as dr_swsgs
         >         from dwd.base_acd_file 
         >         group by substr(sgfssj,1,10)
         > )t1
         > )tt1
         > order by tt1.tjrq;
Time taken: 4.13 seconds, Fetched 4966 row(s)
22/07/05 15:20:00 INFO thriftserver.SparkSQLCLIDriver: Time taken: 4.13 seconds, Fetched 4966 row(s)
spark-sql> select tt1.tjrq
         >         ,tt1.dr_sgs
         >         ,tt1.jn_sgs
         >         ,tt1.qntq_sgs
         >         ,tt1.dr_swsgs
         >         ,tt1.jn_swsgs
         >         ,tt1.qntq_swsgs
         > 
         >         ,NVL(round((abs(tt1.dr_sgs-tt1.qntq_sgs)/NVL(tt1.qntq_sgs,1))*100,2),0) as tb_sgs
         >         ,if(tt1.dr_sgs-tt1.qntq_sgs>0,"上升",'下降') as tb_sgs_bj
         > 
         >         ,NVL(round((abs(tt1.dr_swsgs-tt1.qntq_swsgs)/NVL(tt1.qntq_swsgs,1))*100,2),0) as tb_swsgs
         >         ,if(tt1.dr_swsgs-tt1.qntq_swsgs>0,"上升",'下降') as tb_swsgs_bj
         > from(
         >     select t1.tjrq
         >         ,t1.dr_sgs
         >         ,t1.dr_swsgs
         > 
         >         ,sum(t1.dr_sgs)over (partition by substr(t1.tjrq,1,4))as jn_sgs
         >         ,lag(t1.dr_sgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_sgs
         > 
         >         ,sum(t1.dr_swsgs)over (partition by substr(t1.tjrq,1,4))as jn_swsgs
         >         ,lag(t1.dr_swsgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_swsgs
         >     from(
         >         select substr(sgfssj,1,10)as tjrq
         >             ,count(1)as dr_sgs
         >             ,sum(if(swrs7>0,1,0))as dr_swsgs
         >         from dwd.base_acd_file 
         >         group by substr(sgfssj,1,10)
         > )t1
         > )tt1
         > order by tt1.tjrq;
Time taken: 5.653 seconds, Fetched 4966 row(s)
22/07/05 15:23:09 INFO thriftserver.SparkSQLCLIDriver: Time taken: 5.653 seconds, Fetched 4966 row(s)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。
Python交通事故统计分析是通过使用Python编程语言来对交通事故数据进行分析和统计的过程。在这个过程中,我们可以使用各种数据分析库和机器学习模型来预测交通事故的严重程度,并为交通政府制定更有效的交通事故预防措施和政策提供科学依据。 首先,我们可以使用pandas库来读取交通事故数据,并使用data.head()方法来查看数据的前几行,以便了解数据的结构和内容。然后,我们可以使用numpy、matplotlib和seaborn等库来进行数据探索和可视化,以分析影响交通事故严重程度的各种因素。 接下来,我们可以使用机器学习模型来建立一个准确、可靠的预测模型。根据数据分析的结果,我们可以确定哪些变量对交通事故的严重程度有显著影响。然后,我们可以选择合适的机器学习算法,例如决策树、随机森林或支持向量机等,来训练模型并进行预测。 最后,我们可以使用模型评估指标(例如准确率、召回率和F1分数)来评估模型的性能,并进行模型的调优和改进。通过这个过程,我们可以得到一个准确、可靠的预测模型,用于预测交通事故的严重程度,并为交通政府制定相应的预防措施和政策提供科学依据。 总结起来,Python交通事故统计分析是通过使用Python编程语言和数据分析库,对交通事故数据进行分析和建模的过程,旨在预测交通事故的严重程度,并为交通政府制定更有效的预防措施和政策提供科学依据。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值