Created
June 6, 2021 16:43
-
-
Save AdroitAnandAI/69d5c3a76751306aabc842f7f37c7e35 to your computer and use it in GitHub Desktop.
Combine Features for Spark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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