当前位置:网站首页>pyspark.sql之实现collect_list的排序
pyspark.sql之实现collect_list的排序
2022-08-09 14:55:00 【yisun123456】
通过利用pyspark.sql.Window实现collect_list的排序
from pyspark.sql.window import Window
window_ = Window.partitionBy("userid").orderBy("stay_start_time")
df42= df3.join(df41,'userid','inner').withColumn('lng_lat',concat_ws(',',col('stay_lng'),col('stay_lat')))\
.withColumn("lng_lats",F.collect_list("lng_lat").over(window_))\
.groupby('userid','lng','lat').agg(F.max("lng_lats").alias("lng_lats"))\
.withColumn("lng_lats",concat_ws(';',col('lng_lats')))\
.cache()
df42.show(truncate=False)
边栏推荐
- 记一次解决Mysql:Incorrect string value: ‘\xF0\x9F\x8D\x83\xF0\x9F...‘ for column 插入emoji表情报错问题
- Seize the opportunity of quantitative trading fund products, and quantitative investment has room for development?
- stream去重相同属性对象
- ASP.Net Core实战——使用Swagger
- 编译器不同,模式不同,对结果的影响
- Server运维:设置.htaccess按IP和UA禁止访问
- 【C语言初阶】求最小公倍数的三种方法
- 浏览器指纹识别是什么意思?
- 量子力学初步
- Different compilers, different modes, impact on results
猜你喜欢
随机推荐
How can I know if quantitative programmatic trading is effective?
Different compilers, different modes, impact on results
【小白必看】初始C语言(上)
Analysis: Which method is used to build a stock quantitative trading database?
【C语言初阶】详解分支语句
常微分方程的幂级数解法
实现一个支持请求失败后重试的JS方法
Talking about quantitative trading and programmatic trading
Simply record offsetof and container_of
MIUI12.1.5安装google App store,无需ROOT,不闪退
英语议论文读写02 Engineering
小型项目如何使用异步任务管理器实现不同业务间的解耦
.Net Core后台任务启停(BackgroundService)
链游是什么意思 链游和游戏的区别是什么
Database multi-table link query method
【C语言初阶】倒置字符串(输入 I like beijing. 输出beijing. like I)
ASP.Net Core实战——使用Swagger
NetCore 5.0连接MySql
常见编译问题
文件操作的实例——下载并合并流式视频文件









