from pyspark.ml import Pipeline
from pyspark.ml.feature import StringIndexer
indexers = [StringIndexer(inputCol=column, outputCol=column + '_index').fit
    (df) for column in list(set(df.columns) - set(['date']))]
Apply StringIndexer to several columns in a PySpark Dataframe