code: def _str_extract_frame(arr, pat, flags=0):
      
      from pandas import DataFrame
  
      regex = re.compile(pat, flags=flags)
      groups_or_na = _groups_or_na_fun(regex)
      names = dict(zip(regex.groupindex.values(), regex.groupindex.keys()))
      columns = [names.get(1 + i, i) for i in range(regex.groups)]
  
      if len(arr) == 0:
          return DataFrame(columns=columns, dtype=object)
      try:
          result_index = arr.index
      except AttributeError:
          result_index = None
      return DataFrame(
          [groups_or_na(val) for val in arr],
          columns=columns,
          index=result_index,
          dtype=object)
docs: For each subject string in the Series, extract groups from the
      first match of regular expression pat. This function is called from
      str_extract(expand=True), and always returns a DataFrame.