I\'m using PySpark and I have a Spark dataframe with a bunch of numeric columns. I want to add a column that is the sum of all the other columns.
Suppose my datafram
The most straight forward way of doing it is to use the expr function
expr
from pyspark.sql.functions import * data = data.withColumn('total', expr("col1 + col2 + col3 + col4"))