Skip to content

Commit affeeb7

Browse files
author
VinceShieh
committed
doctest
Signed-off-by: VinceShieh <[email protected]>
1 parent f1d9bcb commit affeeb7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

python/pyspark/ml/feature.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,8 +1938,10 @@ class StringIndexer(JavaEstimator, HasInputCol, HasOutputCol, JavaMLReadable, Ja
19381938
>>> testData2 = sc.parallelize([Row(id=0, label="a"), Row(id=1, label="d"),
19391939
... Row(id=2, label="e")], 2)
19401940
>>> dfKeep= spark.createDataFrame(testData2)
1941-
>>> tdK = stringIndexer.setHandleInvalid("keep").fit(stringIndDf).transform(dfKeep)
1942-
>>> itdK = inverter.transform(tdK)
1941+
>>> modelKeep = stringIndexer.setHandleInvalid("keep").fit(stringIndDf)
1942+
>>> tdK = modelKeep.transform(dfKeep)
1943+
>>> itdK = IndexToString(inputCol="indexed", outputCol="label2",
1944+
... labels=modelKeep.labels).transform(tdK)
19431945
>>> sorted(set([(i[0], str(i[1])) for i in itdK.select(itdK.id, itdK.label2).collect()]),
19441946
... key=lambda x: x[0])
19451947
[(0, 'a'), (6, 'd'), (6, 'e')]

0 commit comments

Comments
 (0)