我正在从pyspark中的mapInPandas函数传递数据帧。所以我需要ID列的所有值都应该用逗号(,)分隔,就像这样'H57R6HU87','A1924334','496A4806'
x1['ID']看起来像这样
H57R6HU87
A1924334
496A4806'
这是我获得唯一ID的代码,我得到的是类型错误:字符串索引必须是整数
# batch_iter= cust.toPandas()
for x1 in batch_iter:
IDs= ','.join(f"'{i}'" for i in x1['ID'].unique())
您可能不需要循环,请尝试:
或者,您可以尝试仅使用Spark功能:
如果要使用
mapInPandas
,请执行以下操作:相关问题 更多 >
编程相关推荐