how many ways are there to add a new column to a data frame RDD in Spark API?
<p>I can think of one only using withColumn():</p>

<pre><code>val df = sc.dataFrame.withColumn('newcolname',{ lambda row: row + 1 } ) 
</code></pre>

<p>but how would I generalize this to Text data? For example of my DataFrame had</p>

<p>strning values say "This is an example of a string" and I wanted to extract the</p>

<p>first and last word as in val arraystring : Array[String] = Array(first,last) </p>