Pandas converting String object to lower case and checking for string
I'm a bit late to the party, but you could use the keyarg case : bool, default True, If True, case sensitive.
private["ISH"] = private.HolidayName.str.contains("holiday|recess", case=False)
public["ISH"] = public.HolidayName.str.contains("holiday|recess", case=False)
private["ISH"] = private.HolidayName.str.contains("(?i)holiday|recess")
The (?i)
in the regex pattern tells the re
module to ignore case.
The reason why you were getting an error is because the Series object does not have the contains
method; instead the Series.str
attribute has the contains
method. So you could avoid the error with:
private["ISH"] = private.HolidayName.str.lower().str.contains("holiday|recess")