错误TypeError:“列"对象在struct的pyspark数据帧中不可调用 [英] ERROR TypeError: 'Column' object is not callable in pyspark data frame of struct
本文介绍了错误TypeError:“列"对象在struct的pyspark数据帧中不可调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的结构PM包含不同的"Pr". 我想在PM STRUCT中计算nbr个不同元素Pr.
I have struct PM that contains different "Pr". I want to count nbr of distinct elements Pr in the PM STRUCT.
代码
schema = StructType(
[
StructField('PM',
StructType([
StructField('Pr', StringType(),True),
StructField('Rd', StringType(),True)
])
),
])
df = sqlCtx.createDataFrame(data, schema)
print(df.PM.select(F.countDistinct("Pr")))
错误 TypeError:列"对象不可调用
ERROR TypeError: 'Column' object is not callable
推荐答案
类似的东西:
df.select('PM.pr').distinct().count()
这篇关于错误TypeError:“列"对象在struct的pyspark数据帧中不可调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文