MCPcopy
hub / github.com/pandas-dev/pandas / findall

Method findall

pandas/core/strings/accessor.py:3239–3329  ·  view source on GitHub ↗

Find all occurrences of pattern or regular expression in the Series/Index. Equivalent to applying :func:`re.findall` to all the elements in the Series/Index. Parameters ---------- pat : str Pattern or regular expression. flags :

(self, pat, flags: int = 0)

Source from the content-addressed store, hash-verified

3237
3238 @forbid_nonstring_types(["bytes"])
3239 def findall(self, pat, flags: int = 0):
3240 """
3241 Find all occurrences of pattern or regular expression in the Series/Index.
3242
3243 Equivalent to applying :func:`re.findall` to all the elements in the
3244 Series/Index.
3245
3246 Parameters
3247 ----------
3248 pat : str
3249 Pattern or regular expression.
3250 flags : int, default 0
3251 Flags from ``re`` module, e.g. `re.IGNORECASE` (default is 0, which
3252 means no flags).
3253
3254 Returns
3255 -------
3256 Series/Index of lists of strings
3257 All non-overlapping matches of pattern or regular expression in each
3258 string of this Series/Index.
3259
3260 See Also
3261 --------
3262 count : Count occurrences of pattern or regular expression in each string
3263 of the Series/Index.
3264 extractall : For each string in the Series, extract groups from all matches
3265 of regular expression and return a DataFrame with one row for each
3266 match and one column for each group.
3267 re.findall : The equivalent ``re`` function to all non-overlapping matches
3268 of pattern or regular expression in string, as a list of strings.
3269
3270 Examples
3271 --------
3272 >>> s = pd.Series(["Lion", "Monkey", "Rabbit"])
3273
3274 The search for the pattern 'Monkey' returns one match:
3275
3276 >>> s.str.findall("Monkey")
3277 0 []
3278 1 [Monkey]
3279 2 []
3280 dtype: object
3281
3282 On the other hand, the search for the pattern 'MONKEY' doesn't return any
3283 match:
3284
3285 >>> s.str.findall("MONKEY")
3286 0 []
3287 1 []
3288 2 []
3289 dtype: object
3290
3291 Flags can be added to the pattern or regular expression. For instance,
3292 to find the pattern 'MONKEY' ignoring the case:
3293
3294 >>> import re
3295 >>> s.str.findall("MONKEY", flags=re.IGNORECASE)
3296 0 []

Callers 15

time_findallMethod · 0.80
get_authorsFunction · 0.80
get_pull_requestsFunction · 0.80
_str_countMethod · 0.80
str_extractallFunction · 0.80
_str_findallMethod · 0.80
get_localesFunction · 0.80
_parse_nodesMethod · 0.80
_validate_pathMethod · 0.80
_validate_namesMethod · 0.80
_get_font_namesMethod · 0.80
colorFunction · 0.80

Calls 2

_wrap_resultMethod · 0.95
_str_findallMethod · 0.45

Tested by 9

test_findallFunction · 0.64
test_findall_lookaroundsFunction · 0.64
test_flags_kwargFunction · 0.64
test_empty_str_methodsFunction · 0.64
test_long_seriesMethod · 0.64
test_unique_idMethod · 0.64
test_str_findallFunction · 0.64