Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Bucketizer pyspark

x = [(0,18.0),(1,19.0),(2,8.0),(3,5.0),(4,2.2),(5,4.0)]
d = spark.createDataFrame(x,["id","hour"])
d.show()
from pyspark.ml.feature import Bucketizer
splits = [0,1,2,3,4,float("Inf")]
buck = Bucketizer(splits=splits,inputCol="BATHSTOTAL",outputCol="baths")
df = buck.transform(df)
df[["BATHSTOTAL","baths"]].show()
 
PREVIOUS NEXT
Tagged: #Bucketizer #pyspark
ADD COMMENT
Topic
Name
4+9 =