Jay*_*Jay 1 python apache-spark-sql
对于新手问题表示歉意。我刚刚学习。
我只是尝试从 Cloudant 数据库创建 Spark 数据帧并计算条目数。调用函数进行计数后,出现错误:
AttributeErrorTraceback (most recent call last)
<ipython-input-5-56a7e10a510b> in <module>()
----> 1 count(cloudantdata,spark)
<ipython-input-2-f2dcd9d73d7e> in count(df, spark)
1 def count(df,spark):
2 #TODO Please enter your code here
----> 3 df.count().show()
4 return
AttributeError: 'int' object has no attribute 'show'
Run Code Online (Sandbox Code Playgroud)
count()是一个操作(与转换相对),因此它返回一个非 DataFrame 对象 - 在本例中int表示 DataFrame 中的行数。Anint没有调用show()它的方法。
就简单了return df.count()。
| 归档时间: |
|
| 查看次数: |
14116 次 |
| 最近记录: |