📜  StringIndexer pyspark - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:16.084000             🧑  作者: Mango

代码示例1
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()