java简单编程字符串处理
2026/5/16 2:34:31
博主介绍:✌全网粉丝50W+,前互联网大厂软件研发、集结硕博英豪成立软件开发工作室,专注于计算机相关专业项目实战6年之久,累计开发项目作品上万套。凭借丰富的经验与专业实力,已帮助成千上万的学生顺利毕业,选择我们,就是选择放心、选择安心毕业✌
> 🍅想要获取完整文章或者源码,或者代做,拉到文章底部即可与我联系了。🍅点击查看作者主页,了解更多项目!
🍅感兴趣的可以先收藏起来,点赞、关注不迷路,大家在毕设选题,项目以及论文编写等相关问题都可以给我留言咨询,希望帮助同学们顺利毕业 。🍅
1、毕业设计:2026年计算机专业毕业设计选题汇总(建议收藏)✅
2、最全计算机大数据专业毕业设计选题大全(建议收藏)✅
技术栈:
Python语言、Django框架、MySQL数据库、深度学习TensorFlow的Keras构建 LSTM 模型、 LSTM 预测算法模型、Echarts可视化、selenium爬虫技术、大众点评数据
大数据技术:Hadoop、Spark、Hive
(1)首页–数据概况
(2)美食类型分析
(3)美食价格分析
(4)美食评价分析
(5)美食地区分析
(6)美食词云图分析
(7)美食数据中心
(8)评价预测----- LSTM 预测算法模型
(9)注册登录
(10)数据采集
#coding:utf8#导包frompyspark.sqlimportSparkSessionfrompyspark.sql.functionsimportmonotonically_increasing_idfrompyspark.sql.typesimportStructType,StructField,IntegerType,StringType,FloatTypefrompyspark.sql.functionsimportcount,mean,col,sum,when,max,min,avgfrompyspark.sqlimportfunctionsasFif__name__=='__main__':#构建spark=SparkSession.builder.appName("sparkSQL").master("local[*]").\ config("spark.sql.shuffle.partitions",2).\ config("spark.sql.warehouse.dir","hdfs://node1:8020/user/hive/warehouse").\ config("hive.metastore.uris","thrift://node1:9083").\ enableHiveSupport().\ getOrCreate()sc=spark.sparkContext#读取fooddata=spark.read.table("fooddata")#需求一 价格TOP10评分top_ten_price=fooddata.orderBy(fooddata.avgPrice.desc()).limit(10)result1=top_ten_price.select("title","start","avgPrice")df=result1.toPandas()# print(df)# sqlresult1.write.mode("overwrite").\format("jdbc").\ option("url","jdbc:mysql://node1:3306/bigdata?useSSL=false&useUnicode=true&charset=utf8").\ option("dbtable","maxPriceTop").\ option("user","root").\ option("password","root").\ option("encoding","utf-8").\ save()result1.write.mode("overwrite").saveAsTable("maxPriceTop","parquet")spark.sql("select * from maxPriceTop").show()#需求二 totalTyperesult2=fooddata.groupby("totalType").count()# sqlresult2.write.mode("overwrite").\format("jdbc").\ option("url","jdbc:mysql://node1:3306/bigdata?useSSL=false&useUnicode=true&charset=utf8").\ option("dbtable","typeCount").\ option("user","root").\ option("password","root").\ option("encoding","utf-8").\ save()result2.write.mode("overwrite").saveAsTable("typeCount","parquet")spark.sql("select * from typeCount").show()#需求三 城市均价reuslt3=fooddata.groupby("city").agg(F.avg("avgPrice").alias("averagePrice"))# sqlreuslt3.write.mode("overwrite").\format("jdbc").\ option("url","jdbc:mysql://node1:3306/bigdata?useSSL=false&useUnicode=true&charset=utf8").\ option("dbtable","cityAvg").\ option("user","root").\ option("password","root").\ option("encoding","utf-8").\ save()reuslt3.write.mode("overwrite").saveAsTable("cityAvg","parquet")spark.sql("select * from cityAvg").show()#类型分析result4=fooddata.groupby("totalType").agg(avg("totalComment").alias("commentAvg"))# sqlresult4.write.mode("overwrite").\format("jdbc").\ option("url","jdbc:mysql://node1:3306/bigdata?useSSL=false&useUnicode=true&charset=utf8").\ option("dbtable","typeComment").\ option("user","root").\ option("password","root").\ option("encoding","utf-8").\ save()result4.write.mode("overwrite").saveAsTable("typeComment","parquet")spark.sql("select * from typeComment").show()#需求五result5=fooddata.groupby("totalType").agg(avg("tasterate").alias("avgTasterate"),avg("envsrate").alias("avgEnvsrate"),avg("serverate").alias("avgServerate"),)# sqlresult5.write.mode("overwrite").\format("jdbc").\ option("url","jdbc:mysql://node1:3306/bigdata?useSSL=false&useUnicode=true&charset=utf8").\ option("dbtable","typeRate").\ option("user","root").\ option("password","root").\ option("encoding","utf-8").\ save()result5.write.mode("overwrite").saveAsTable("typeRate","parquet")spark.sql("select * from typeRate").show()#需求6 精确类型result6=fooddata.groupby("type").count()# sqlresult6.write.mode("overwrite").\format("jdbc").\ option("url","jdbc:mysql://node1:3306/bigdata?useSSL=false&useUnicode=true&charset=utf8").\ option("dbtable","specificType").\ option("user","root").\ option("password","root").\ option("encoding","utf-8").\ save()result6.write.mode("overwrite").saveAsTable("specificType","parquet")spark.sql("select * from specificType").show()#需求七 价格分析reuslt7=fooddata.groupby("city").agg(max("avgPrice").alias("maxAvgPrice"))# sqlreuslt7.write.mode("overwrite").\format("jdbc").\ option("url","jdbc:mysql://node1:3306/bigdata?useSSL=false&useUnicode=true&charset=utf8").\ option("dbtable","maxPriceCity").\ option("user","root").\ option("password","root").\ option("encoding","utf-8").\ save()reuslt7.write.mode("overwrite").saveAsTable("maxPriceCity","parquet")spark.sql("select * from maxPriceCity").show()#需求八 价格分类fooddata_with_category=fooddata.withColumn("prcieCategory",when(col("avgPrice").between(0,15),'0-15元').when(col("avgPrice").between(15,50),'15-50元').when(col("avgPrice").between(50,100),'50-100元').when(col("avgPrice").between(100,200),'100-200元').when(col("avgPrice").between(200,500),'200-500元').otherwise('500以上'))reuslt8=fooddata_with_category.groupby("prcieCategory").count()# sqlreuslt8.write.mode("overwrite").\format("jdbc").\ option("url","jdbc:mysql://node1:3306/bigdata?useSSL=false&useUnicode=true&charset=utf8").\ option("dbtable","categoryPrice").\ option("user","root").\ option("password","root").\ option("encoding","utf-8").\ save()reuslt8.write.mode("overwrite").saveAsTable("categoryPrice","parquet")spark.sql("select * from categoryPrice").show()# 类型均价reuslt9=fooddata.groupby("totalType").agg(avg("avgPrice").alias("allAvgPrice"))# sqlreuslt9.write.mode("overwrite").\format("jdbc").\ option("url","jdbc:mysql://node1:3306/bigdata?useSSL=false&useUnicode=true&charset=utf8").\ option("dbtable","typePrice").\ option("user","root").\ option("password","root").\ option("encoding","utf-8").\ save()reuslt9.write.mode("overwrite").saveAsTable("typePrice","parquet")spark.sql("select * from typePrice").show()#需求十 星级分布result10=fooddata.groupby("start").count()# sqlresult10.write.mode("overwrite").\format("jdbc").\ option("url","jdbc:mysql://node1:3306/bigdata?useSSL=false&useUnicode=true&charset=utf8").\ option("dbtable","startCount").\ option("user","root").\ option("password","root").\ option("encoding","utf-8").\ save()result10.write.mode("overwrite").saveAsTable("startCount","parquet")spark.sql("select * from startCount").show()#需求十一fooddata_with_mixrate=fooddata.withColumn("mixrate",col("tasterate")+col("envsrate")+col("serverate"))reuslt11=fooddata_with_mixrate.groupby("city").agg(avg("mixrate").alias("avgMixrate"))# sqlreuslt11.write.mode("overwrite").\format("jdbc").\ option("url","jdbc:mysql://node1:3306/bigdata?useSSL=false&useUnicode=true&charset=utf8").\ option("dbtable","mixrateAvg").\ option("user","root").\ option("password","root").\ option("encoding","utf-8").\ save()reuslt11.write.mode("overwrite").saveAsTable("mixrateAvg","parquet")spark.sql("select * from mixrateAvg").show()# 价格最大最小result12=fooddata.groupby("city").agg(max("avgPrice").alias("maxAvfPrice"),avg("avgPrice").alias("avgAvfPrice"),min("avgPrice").alias("minAvfPrice"),)# sqlresult12.write.mode("overwrite").\format("jdbc").\ option("url","jdbc:mysql://node1:3306/bigdata?useSSL=false&useUnicode=true&charset=utf8").\ option("dbtable","mamCity").\ option("user","root").\ option("password","root").\ option("encoding","utf-8").\ save()result12.write.mode("overwrite").saveAsTable("mamCity","parquet")spark.sql("select * from mamCity").show()#需求十三total_comments_df=fooddata.groupby("address").agg(sum("totalComment").alias("sumTotalComment"))reuslt13=total_comments_df.orderBy(col("sumTotalComment").desc()).limit(10)# sqlreuslt13.write.mode("overwrite").\format("jdbc").\ option("url","jdbc:mysql://node1:3306/bigdata?useSSL=false&useUnicode=true&charset=utf8").\ option("dbtable","hotAddress").\ option("user","root").\ option("password","root").\ option("encoding","utf-8").\ save()reuslt13.write.mode("overwrite").saveAsTable("hotAddress","parquet")spark.sql("select * from hotAddress").show()🍅✌感兴趣的可以先收藏起来,点赞关注不迷路,想学习更多项目可以查看主页,大家在毕设选题,项目编程以及论文编写等相关问题都可以给我留言咨询,希望可以帮助同学们顺利毕业!🍅✌
🍅由于篇幅限制,获取完整文章或源码、代做项目的,拉到文章底部即可看到个人联系方式。🍅
点赞、收藏、关注,不迷路,下方查看👇🏻获取联系方式👇🏻