phase input should be string, not <class 'float'>
error appears I don't know how to squeeze more code;
We've turned the code with reference to the collar below, and we're in progress with the data that we crawled directly https://github.com/threegenie/sentiment_project/blob/main/kakaopage_playstore_review_analysis.ipynb
The heads are as follows:
>>> import pandas as pd
>>> from konlpy.tag import Okt
>>>
>>> df = pd.DataFrame({"Review"):["It was delicious", "Too salty".", "", "."]})
>>> okt = Okt()
>>> df["tok"] = df["Review"].apply(okt.morphs)
>>> df
Review tok
0 It was delicious. [It was delicious]
1 is too salty. [Too salty]
2 []
3 . [.]
>>> import numpy as np
>>> df["Review1"] = df["Review"].replace("", np.nan)
>>> df["tok1"] = df["Review1"].apply(okt.morphs)
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
df["tok1"] = df["Review1"].apply(okt.morphs)
File "C:\PROGRAMS\Python3864\lib\site-packages\pandas\core\series.py", line 4357, in apply
return SeriesApply(self, func, convert_dtype, args, kwargs).apply()
File "C:\PROGRAMS\Python3864\lib\site-packages\pandas\core\apply.py", line 1043, in apply
return self.apply_standard()
File "C:\PROGRAMS\Python3864\lib\site-packages\pandas\core\apply.py", line 1098, in apply_standard
mapped = lib.map_infer(
File "pandas\_libs\lib.pyx", line 2859, in pandas._libs.lib.map_infer
File "C:\PROGRAMS\Python3864\lib\site-packages\konlpy\tag\_okt.py", line 89, in morphs
return [s for s, t in self.pos(phrase, norm=norm, stem=stem)]
File "C:\PROGRAMS\Python3864\lib\site-packages\konlpy\tag\_okt.py", line 69, in pos
validate_phrase_inputs(phrase)
File "C:\PROGRAMS\Python3864\lib\site-packages\konlpy\tag\_common.py", line 20, in validate_phrase_inputs
assert isinstance(phrase, basestring), msg
AssertionError: phrase input should be string, not <class 'float'>
I shouldn't replace it. Error when executing okt.morphs for np.nan.
© 2024 OneMinuteCode. All rights reserved.