擅长:python、mysql、java
<p>我来自scala,但我相信python中也有类似的方法:</p>
<p>使用<a href="http://spark.apache.org/docs/latest/api/scala/index.html#org.apache.spark.sql.functions$" rel="noreferrer">^{<cd1>}</a>包方法:</p>
<p>如果要使用这三列获得<code>StructType</code>方法,请使用如下<code>struct(cols: Column*): Column</code>方法:</p>
<pre><code>from pyspark.sql.functions import struct
df.withColumn("V_tuple",struct(df.V1,df.V2,df.V3))
</code></pre>
<p>但是如果你想把它作为一个字符串,你可以像这样使用<code>concat(exprs: Column*): Column</code>方法:</p>
<pre><code>from pyspark.sql.functions import concat
df.withColumn("V_tuple",concat(df.V1,df.V2,df.V3))
</code></pre>
<p>使用第二种方法,您可能必须将列强制转换为<code>String</code>s</p>
<p>我不确定python语法,如果有语法错误,请编辑答案。</p>
<p>希望这对你有帮助。致意</p>