Untitled
unknown
plain_text
3 years ago
3.4 kB
8
Indexable
TypeError Traceback (most recent call last)
Input In [36], in <cell line: 3>()
1 ## NeatText is a package for simplifying text
----> 3 Incident_Data['ticket_desc']=Incident_Data['ticket_desc'].apply(nfx.remove_special_characters)
4 Incident_Data['ticket_desc']=Incident_Data['ticket_desc'].apply(nfx.remove_stopwords)
5 Incident_Data['ticket_desc']=Incident_Data['ticket_desc'].apply(nfx.remove_multiple_spaces)
File /Analytics/venv/CAPEANALYTICS/lib/python3.8/site-packages/pandas/core/series.py:4357, in Series.apply(self, func, convert_dtype, args, **kwargs)
4247 def apply(
4248 self,
4249 func: AggFuncType,
(...)
4252 **kwargs,
4253 ) -> FrameOrSeriesUnion:
4254 """
4255 Invoke function on values of Series.
4256
(...)
4355 dtype: float64
4356 """
-> 4357 return SeriesApply(self, func, convert_dtype, args, kwargs).apply()
File /Analytics/venv/CAPEANALYTICS/lib/python3.8/site-packages/pandas/core/apply.py:1043, in SeriesApply.apply(self)
1039 if isinstance(self.f, str):
1040 # if we are a string, try to dispatch
1041 return self.apply_str()
-> 1043 return self.apply_standard()
File /Analytics/venv/CAPEANALYTICS/lib/python3.8/site-packages/pandas/core/apply.py:1098, in SeriesApply.apply_standard(self)
1092 values = obj.astype(object)._values
1093 # error: Argument 2 to "map_infer" has incompatible type
1094 # "Union[Callable[..., Any], str, List[Union[Callable[..., Any], str]],
1095 # Dict[Hashable, Union[Union[Callable[..., Any], str],
1096 # List[Union[Callable[..., Any], str]]]]]"; expected
1097 # "Callable[[Any], Any]"
-> 1098 mapped = lib.map_infer(
1099 values,
1100 f, # type: ignore[arg-type]
1101 convert=self.convert_dtype,
1102 )
1104 if len(mapped) and isinstance(mapped[0], ABCSeries):
1105 # GH 25959 use pd.array instead of tolist
1106 # so extension arrays can be used
1107 return obj._constructor_expanddim(pd_array(mapped), index=obj.index)
File /Analytics/venv/CAPEANALYTICS/lib/python3.8/site-packages/pandas/_libs/lib.pyx:2859, in pandas._libs.lib.map_infer()
File /Analytics/venv/CAPEANALYTICS/lib/python3.8/site-packages/neattext/functions/functions.py:90, in remove_special_characters(text)
88 def remove_special_characters(text):
89 """Returns A String with the specified characters removed """
---> 90 result = re.sub(SPECIAL_CHARACTERS_REGEX, "", text)
91 return result
File /Analytics/python3/lib/python3.8/re.py:210, in sub(pattern, repl, string, count, flags)
203 def sub(pattern, repl, string, count=0, flags=0):
204 """Return the string obtained by replacing the leftmost
205 non-overlapping occurrences of the pattern in string by the
206 replacement repl. repl can be either a string or a callable;
207 if a string, backslash escapes in it are processed. If it is
208 a callable, it's passed the Match object and must return
209 a replacement string to be used."""
--> 210 return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like objectEditor is loading...