You are passing a list of primitives. It expects something like a list of
tuples, which can each have 1 int if you like.

On Sun, Feb 6, 2022, 10:10 PM <capitnfrak...@free.fr> wrote:

> >>> rdd = sc.parallelize([3,2,1,4])
> >>> rdd.toDF().show()
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
>    File "/opt/spark/python/pyspark/sql/session.py", line 66, in toDF
>      return sparkSession.createDataFrame(self, schema, sampleRatio)
>    File "/opt/spark/python/pyspark/sql/session.py", line 675, in
> createDataFrame
>      return self._create_dataframe(data, schema, samplingRatio,
> verifySchema)
>    File "/opt/spark/python/pyspark/sql/session.py", line 698, in
> _create_dataframe
>      rdd, schema = self._createFromRDD(data.map(prepare), schema,
> samplingRatio)
>    File "/opt/spark/python/pyspark/sql/session.py", line 486, in
> _createFromRDD
>      struct = self._inferSchema(rdd, samplingRatio, names=schema)
>    File "/opt/spark/python/pyspark/sql/session.py", line 466, in
> _inferSchema
>      schema = _infer_schema(first, names=names)
>    File "/opt/spark/python/pyspark/sql/types.py", line 1067, in
> _infer_schema
>      raise TypeError("Can not infer schema for type: %s" % type(row))
> TypeError: Can not infer schema for type: <class 'int'>
>
>
> In my pyspark why this fails? I didnt get the way.
> Thanks for helps.
>
> ---------------------------------------------------------------------
> To unsubscribe e-mail: user-unsubscr...@spark.apache.org
>
>

Reply via email to