Hive 将pyspark中字符串数组的一列转换为一列中的多行

Hive 将pyspark中字符串数组的一列转换为一列中的多行,hive,pyspark,Hive,Pyspark,我想在databricks pyspark上转换一个列为字符串数组的表 我的桌子: id values (array<string>) rgf ['vwervfrev', 'fweccf', 'tuyhert'] rty ['evvverws', 'ilonmunt', 'cedcrhb'] 我不知道如何进行转换 谢谢您可以使用explode功能执行此操作: from pyspark.sql.functions import ex

我想在databricks pyspark上转换一个列为字符串数组的表

我的桌子:

 id         values  (array<string>)
 rgf        ['vwervfrev', 'fweccf', 'tuyhert']
 rty        ['evvverws', 'ilonmunt', 'cedcrhb']
我不知道如何进行转换


谢谢

您可以使用explode功能执行此操作:

from pyspark.sql.functions import explode, col

new_df = df.withColumn("values", explode(col("values")))
new_df.show()

from pyspark.sql.functions import explode, col

new_df = df.withColumn("values", explode(col("values")))
new_df.show()