📅  最后修改于: 2022-03-11 14:47:16.084000             🧑  作者: Mango
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()