我正在读取包含大约50列的csv文件中的数据,其中有几列(4到5列)包含非ASCII字符和特殊字符的文本数据。
df = spark.read.csv(path, header=True, schema=availSchema)
我正在尝试删除所有非ASCII和特殊字符,只保留英文字符,并且我尝试以下操作:
df = df['textcolumn'].str.encode('ascii', 'ignore').str.decode('ascii')
我的列名中没有空格,但我收到了一个错误提示。
TypeError: 'Column' object is not callable
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<command-1486957561378215> in <module>
----> 1 InvFilteredDF = InvFilteredDF['SearchResultDescription'].str.encode('ascii', 'ignore').str.decode('ascii')
TypeError: 'Column' object is not callable
有没有其他方法可以实现这个,非常感谢您的帮助。