def _groups_or_na_fun(regex):
 if (regex.groups == 0):
  raise ValueError('pattern contains no capture groups')
 empty_row = ([np.nan] * regex.groups)
 def f(x):
  if (not isinstance(x, compat.string_types)):
   return empty_row
  m = regex.search(x)
  if m:
   return [(np.nan if (item is None) else item) for item in m.groups()]
  else:
   return empty_row
 return f

def _groups_or_na_fun ( regex ) : if ( regex . groups == 0 ) : raise ValueError ( 'pattern contains no capture groups' ) empty_row = ( [ np . nan ] * regex . groups ) def f ( x ) : if ( not isinstance ( x , compat . string_types ) ) : return empty_row m = regex . search ( x ) if m : return [ ( np . nan if ( item is None ) else item ) for item in m . groups ( ) ] else : return empty_row return f
used in both extract_noexpand and extract_frame .