PySpark: TypeError: StructType can not accept object 0.10000000000000001 in type <type 'numpy.float64'>

Viewed 11243

when using PySpark with the following code:

from pyspark.sql.types import *
samples = np.array([0.1,0.2])
dfSchema = StructType([StructField("x", FloatType(), True)])
spark.createDataFrame(samples,dfSchema)

I get:

TypeError: StructType can not accept object 0.10000000000000001 in type type 'numpy.float64'>

Any idea?

1 Answers
Related