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()