Sep-01-2023, 05:40 AM
(Aug-31-2023, 03:53 PM)deanhystad Wrote: I think this is the problem:
m = [False] * len(series)This is not a "Series, Index, or np.array". Try m = numpy.full((len(series), False).
Hi, Thank you.
I tried this but my code started flagging errors(red line) under certain words, I've highlighted all places by putting them inside the square brackets.
def get_flags(series, flags, regex_flag): """ Identifies whether the series contains the flags under consideration. Args: series (pandas.DataFrame.Series): Series against which regular expressions will be matched. flags (list): List of regular expressions to be evaluated """ #m = [False] * len(series[)] m = np.full((len(series), False) series = [series].astype(str).str.lower([)] for i, flag in enumerate(flags): flag = [flag].lower() m = m | series.astype(str).str.contains( flag.lower(), regex=regex_flag, case=True, ) return m