stringindexer pyspark

Solutions on MaxInterview for stringindexer pyspark by the best coders in the world

showing results for - "stringindexer pyspark"
Avaline
23 Mar 2017
1df_i = spark.createDataFrame([
2    ("a", 2.0),
3    ("c", 1.0),
4    ("b", 2.0),    
5    ("a", 1.0),
6    ("a", 0.0),   
7    ("c", 1.0)
8], ["categoryIndex", "categoryIndex2"])
9stringID = StringIndexer(inputCol="categoryIndex",outputCol="categoryIndex2")
10indexer = stringID.fit(df_i)
11df_i = indexer.transform(df_i)
12df_i.show()