【发布时间】:2020-05-15 09:24:43
【问题描述】:
我正在尝试构建一个模式来加载包含以下内容的文件的内容-
- movie_id,字符串
- 电影名称,字符串
- 情节,字符串
- 流派,字符串数组
这是我的架构定义-
customSchema = types.StructType(types.ArrayType(
types.StructField("movie_id", types.StringType(), True),
types.StructField("movie_name", types.StringType(), True),
types.StructField("plot", types.StringType(), True),
types.StructField('genre',
types.ArrayType(types.StringType()), True),
))
这是我得到的错误
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-290-10452c69a6ff> in <module>()
3 types.StructField("movie_name", types.StringType(), True),
4 types.StructField("plot", types.StringType(), True),
----> 5 types.StructField('genre', types.ArrayType(types.StringType()), True),
6 ))
TypeError: __init__() takes from 2 to 3 positional arguments but 5 were given
【问题讨论】:
-
不是
machine-learning问题,请不要发送垃圾邮件无关标签(已删除并替换为apache-spark-sql)。
标签: pyspark apache-spark-sql pyspark-dataframes