0
をI次のPython/Pysparkコードを持っている:Pythonのデータフレームに文字列のリストを変換する - pysparkパイソンsparksql
sql_command = ''' query ''''
df = spark.sql(sql_command)
ls_colnames = df.schema.names
ls_colnames
['id', 'level1', 'level2', 'level3', 'specify_facts']
cSchema = StructType([
StructField("colname", StringType(), False)
])
df_colnames = spark.createDataFrame(dataset_array,schema=cSchema)
File "/opt/mapr/spark/spark-2.1.0/python/pyspark/sql/types.py", line 1366, in _verify_type raise TypeError("StructType can not accept object %r in type %s" % (obj, type(obj))) TypeError: StructType can not accept object 'id' in type class 'str'
私はCOLNAMESのスパークオブジェクトを取得するために何ができますか?私はあなたの質問を正しく理解している場合はわからない `