无法在pyspark中使用.show()显示数据框

时间:2019-04-03 04:15:13

标签: pyspark apache-spark-sql pyspark-sql

代码如下:

from pyspark import *
from pyspark.sql import *

spark=SparkContext()

sc=SQLContext(spark)

valuesA = [('Pirate',1),('Monkey',2),('Ninja',3),('Spaghetti',4)]

TableA = sc.createDataFrame(valuesA,['name','id'])

valuesB = [('Rutabaga',1),('Pirate',2),('Ninja',3),('Darth Vader',4)]

TableB = sc.createDataFrame(valuesB,['name','id'])

TableA.describe('name').show()

错误如下:

---------------------------------------------------------------------------
Py4JJavaError Traceback (most recent call last)
<ipython-input-11-dcdbe2628b72> in <module>
1 TableA.describe('name').show()

1 个答案:

答案 0 :(得分:-1)

请尝试使用如下描述函数:

TableA.describe(['name']).show()