Skip to content

Instantly share code, notes, and snippets.

@AdroitAnandAI
Created June 6, 2021 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdroitAnandAI/69d5c3a76751306aabc842f7f37c7e35 to your computer and use it in GitHub Desktop.
Save AdroitAnandAI/69d5c3a76751306aabc842f7f37c7e35 to your computer and use it in GitHub Desktop.
Combine Features for Spark
from pyspark.ml.feature import VectorAssembler
# Assemble all the features with VectorAssembler
def assembleFeatures(dfRDD):
required_features = ['week',
'temp',
'wind',
'rainfall',
'day',
'humScale'
]
assembler = VectorAssembler(inputCols=required_features, \\
outputCol='features')
transformed_data = assembler.transform(dfRDD)
return transformed_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment