pyspark使用json在dataframe中添加列

2024-04-18 11:23:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个数据帧df3:-

测试3.show()

+----------------------+-------------------+

|count(user_name)|count(team_id)|

+----------------------+-------------------+

| 10 | 10|

+----------------------+-------------------+

我需要在上面添加两列json

^{pr2}$

上面我用StringType作为json的类型不可用

test_df3 = test_df3.withColumn("new",udf(col("count(user_name)"), col("count(team_id)"))).select("new")

关于如何在dataframe列中获取json的任何帮助


Tags: 数据nametestidjson类型newshow