如何将pandas数据帧转换为unicode?
`messages=pandas.read_csv('data/SMSSpamCollection',sep='\t',quoting=csv.QUOTE_NONE,names=["label", "message"])
def split_into_tokens(message):
message = unicode(message, 'utf8') # convert bytes into proper unicode
return TextBlob(message).words
messages.head().apply(split_into_tokens(messages))`
Run Code Online (Sandbox Code Playgroud)
它给出了错误
Traceback (most recent call last):
File "minor.py", line 46, in <module>
messages.head().apply(split_into_tokens(messages))
File "minor.py", line 42, in split_into_tokens
message = unicode(message, 'utf8') # convert bytes into proper unicode
TypeError: coercing to Unicode: need string or buffer, DataFrame found
Run Code Online (Sandbox Code Playgroud) 使用Python执行时,它显示错误:
return (x * (1.0 — x))
^
SyntaxError: invalid character in identifier
Run Code Online (Sandbox Code Playgroud)
我该如何纠正?