pandas 显示单个火花列时,“Column”对象不可调用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51819357/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
`'Column' object is not callable` when showing a single spark column
提问by Nabih Bawazir
I'm a new spark user, and previously I'm from pandas background. Here's my Spark Dataframe
我是一个新的 spark 用户,之前我来自Pandas背景。这是我的 Spark 数据框
In[75]: spDF
Out[75]: DataFrame[customer_id: string, name: string]
and when I show
them
当我show
他们
In[75]: spDF.show()
Out[75]:
+-----------+-----------+
|customer_id| name|
+-----------+-----------+
| 25620| MCDonnalds|
| 25620| STARBUCKS|
| 25620| nan|
| 25620| nan|
| 25620| MCDonnalds|
| 25620| nan|
| 25620| MCDonnalds|
| 25620|DUNKINDONUT|
| 25620| LOTTERIA|
| 25620| nan|
| 25620| MCDonnalds|
| 25620|DUNKINDONUT|
| 25620|DUNKINDONUT|
| 25620| nan|
| 25620| nan|
| 25620| nan|
| 25620| nan|
| 25620| LOTTERIA|
| 25620| LOTTERIA|
| 25620| STARBUCKS|
+-----------+-----------+
only showing top 20 rows
Then I try querying columns only
然后我尝试只查询列
In[76]: spDF['name']
Out[76]: Column<b'name'>
But when I show them, I get the following error.
但是当我向他们展示时,我收到以下错误。
In[79]: spDF['name'].show()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-79-f6676d5e5ca2> in <module>()
----> 1 spDF['name'].show()
TypeError: 'Column' object is not callable
Anyone has an idea, what is this error?
任何人都有一个想法,这是什么错误?
回答by Chandan Ray
Try
尝试
So spDF.select('colname').show()
所以 spDF.select('colname').show()