Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

StringIndexer pyspark

df_i = spark.createDataFrame([
    ("a", 2.0),
    ("c", 1.0),
    ("b", 2.0),    
    ("a", 1.0),
    ("a", 0.0),   
    ("c", 1.0)
], ["categoryIndex", "categoryIndex2"])
stringID = StringIndexer(inputCol="categoryIndex",outputCol="categoryIndex2")
indexer = stringID.fit(df_i)
df_i = indexer.transform(df_i)
df_i.show()
 
PREVIOUS NEXT
Tagged: #StringIndexer #pyspark
ADD COMMENT
Topic
Name
3+6 =