Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PERF: switch to faster try/except in extract()
isinstance check takes longer but accomplishes the same thing.
  • Loading branch information
jtratner committed Sep 7, 2014
commit b209a5106f94f9123a50d7e9187e076ab7ead7ab
4 changes: 3 additions & 1 deletion pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ def str_extract(arr, pat, flags=0):
raise ValueError("This pattern contains no groups to capture.")
empty_row = [np.nan]*regex.groups
def f(x):
if not isinstance(x, compat.string_types):
try:
regex.search(x)
except TypeError:
return empty_row
m = regex.search(x)
if m:
Expand Down