For loop 使用for循环返回pyspark数据帧的问题
我正在申请pyspark中的loop。如何获取dataframe中的实际值。我也在做数据帧连接和过滤 我没有在这里添加数据集,我需要的方法或psuedo代码只是为了弄清楚我在这里做什么 我真的很感激你的帮助,我已经被困很久了For loop 使用for循环返回pyspark数据帧的问题,for-loop,pyspark,For Loop,Pyspark,我正在申请pyspark中的loop。如何获取dataframe中的实际值。我也在做数据帧连接和过滤 我没有在这里添加数据集,我需要的方法或psuedo代码只是为了弄清楚我在这里做什么 我真的很感激你的帮助,我已经被困很久了 values1 = values.collect() temp1 = [] for index, row in enumerate(sorted(values1, key=lambda x:x.w_vote, reverse = False)): tmp = da
values1 = values.collect()
temp1 = []
for index, row in enumerate(sorted(values1, key=lambda x:x.w_vote, reverse = False)):
tmp = data_int.filter(data_int.w_vote >= row.w_vote)
# Left join service types to results
it1 = dt.join(master_info,dt.value == master_info.value, 'left').drop(dt.value)
print(tmp)
it1 = it1.withcolumn('iteration',F.lit('index')).otherwise(it1.iteration1)
it1 = it1.collect()[index]
# concatenate the results to the final hh list
temp1.append(it1)
print ('iterations left:', total_values - (index+1), "Threshold:", row.w_vote)
我面临的问题是temp1的输出如下
DataFrame[value_x: bigint, value_y: bigint, type_x: string, type_y: string, w_vote: double]
iterations left: 240 Threshold: 0.1
DataFrame[value_x: bigint, value_y: bigint, type_x: string, type_y: string, w_vote: double]
iterations left: 239 Threshold: 0.2
为什么我的实际值没有在uutput中显示为应用于数据帧的列表
打印
,请执行数据帧的\uuu repr\uu
方法,这就是您得到的结果。如果要打印数据帧的内容,请使用show
显示前20行,或使用collect
获取完整的数据帧 蒂洛,你最近的活动表明,你自己在解决这些问题上几乎没有什么努力。考虑在每天添加一些帖子之前尝试自己解决这些问题。