@@ -2446,6 +2446,36 @@ def _convert_int_result(self, result):
24462446 def _convert_rank_result (self , result ):
24472447 return type (self )(result )
24482448
2449+ def _str_contains (self , pat , case = True , flags = 0 , na = lib .no_default , regex = True ):
2450+ import re
2451+
2452+ if isinstance (pat , re .Pattern ):
2453+ if flags != 0 :
2454+ # fallback to python object implementation
2455+ return BaseStringArrayMethods ._str_contains (
2456+ self , pat , case , flags , na , regex
2457+ )
2458+ pat = pat .pattern
2459+ regex = True
2460+
2461+ try :
2462+ if not regex :
2463+ result = pc .match_substring (self ._pa_array , pat , ignore_case = not case )
2464+ else :
2465+ result = pc .match_substring_regex (
2466+ self ._pa_array , pat , ignore_case = not case , options = None
2467+ )
2468+ return self ._convert_bool_result (result , na = na , method_name = "contains" )
2469+ except (AttributeError , NotImplementedError , pa .ArrowNotImplementedError ):
2470+ return BaseStringArrayMethods ._str_contains (
2471+ self , pat , case , flags , na , regex
2472+ )
2473+
2474+ def _str_count (self , pat : str , flags : int = 0 ) -> Self :
2475+ if flags :
2476+ raise NotImplementedError (f"count not implemented with { flags = } " )
2477+ return type (self )(pc .count_substring_regex (self ._pa_array , pat ))
2478+
24492479 def _str_count (self , pat : str , flags : int = 0 ) -> Self :
24502480 if flags :
24512481 raise NotImplementedError (f"count not implemented with { flags = } " )
0 commit comments