Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR MATLAB

pyspark dense

import pyspark.sql.functions as F
import pyspark.sql.types as T

#or: to_array = F.udf(lambda v: list([float(x) for x in v]), T.ArrayType(T.FloatType()))
to_array = F.udf(lambda v: v.toArray().tolist(), T.ArrayType(T.FloatType()))
df = df.withColumn('features', to_array('features'))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pyspark #dense
ADD COMMENT
Topic
Name
1+1 =