<分区> 分区>
我得到了编码错误:
UnicodeEncodeError: 'ascii' codec can't encode character u'\ufffd' in position 3: ordinal not in range(128)
在以下 python (pyspark) 代码中,其中行是数据框行:
def rowToLine(row):
line = str(row[0]).strip()
columnNum = 44
for k in xrange(1, columnNum):
line = line + "\t"
line = line + str(row[k]).strip() # encoding error here
return line
我还尝试了下面的连接:
def rowToLine(row):
s = "\t"
return s.join(row)
但是行的某些值是 int,所以我得到了错误:
TypeError: sequence item 19: expected string or Unicode, int found
有人知道怎么解决吗?谢谢!
