parameters: (
      func: Callable[[str], Any], arr: "StringArray", na_value: Any, dtype: Dtype
  )
docstring: Map a callable over valid elements of a StringArrray.
  
      Parameters
      ----------
      func : Callable[[str], Any]
          Apply to each valid element.
      arr : StringArray
      na_value : Any
          The value to use for missing values. By default, this is
          the original value (NA).
      dtype : Dtype
          The result dtype to use. Specifying this avoids an intermediate
          object-dtype allocation.
  
      Returns
      -------
      ArrayLike
          An ExtensionArray for integer or string dtypes, otherwise
          an ndarray.
docstring_summary: Map a callable over valid elements of a StringArrray.
docstring_tokens: Map a callable over valid elements of a StringArrray .
function: def _map_stringarray(
      func: Callable[[str], Any], arr: "StringArray", na_value: Any, dtype: Dtype
  ) -> ArrayLike:
      """
      Map a callable over valid elements of a StringArrray.
  
      Parameters
      ----------
      func : Callable[[str], Any]
          Apply to each valid element.
      arr : StringArray
      na_value : Any
          The value to use for missing values. By default, this is
          the original value (NA).
      dtype : Dtype
          The result dtype to use. Specifying this avoids an intermediate
          object-dtype allocation.
  
      Returns
      -------
      ArrayLike
          An ExtensionArray for integer or string dtypes, otherwise
          an ndarray.
  
      """
      from pandas.arrays import IntegerArray, StringArray, BooleanArray
  
      mask = isna(arr)
  
      assert isinstance(arr, StringArray)
      arr = np.asarray(arr)
  
      if is_integer_dtype(dtype) or is_bool_dtype(dtype):
          constructor: Union[Type[IntegerArray], Type[BooleanArray]]
          if is_integer_dtype(dtype):
              constructor = IntegerArray
          else:
              constructor = BooleanArray
  
          na_value_is_na = isna(na_value)
          if na_value_is_na:
              na_value = 1
          result = lib.map_infer_mask(
              arr,
              func,
              mask.view("uint8"),
              convert=False,
              na_value=na_value,
              dtype=np.dtype(dtype),
          )
  
          if not na_value_is_na:
              mask[:] = False
  
          return constructor(result, mask)
  
      elif is_string_dtype(dtype) and not is_object_dtype(dtype):
          # i.e. StringDtype
          result = lib.map_infer_mask(
              arr, func, mask.view("uint8"), convert=False, na_value=na_value
          )
          return StringArray(result)
      else:
          # This is when the result type is object. We reach this when
          # -> We know the result type is truly object (e.g. .encode returns bytes
          #    or .findall returns a list).
          # -> We don't know the result type. E.g. `.get` can return anything.
          return lib.map_infer_mask(arr, func, mask.view("uint8"))
function_tokens: def _map_stringarray ( func : Callable [ [ str ] , Any ] , arr : "StringArray" , na_value : Any , dtype : Dtype ) -> ArrayLike : from pandas . arrays import IntegerArray , StringArray , BooleanArray mask = isna ( arr ) assert isinstance ( arr , StringArray ) arr = np . asarray ( arr ) if is_integer_dtype ( dtype ) or is_bool_dtype ( dtype ) : constructor : Union [ Type [ IntegerArray ] , Type [ BooleanArray ] ] if is_integer_dtype ( dtype ) : constructor = IntegerArray else : constructor = BooleanArray na_value_is_na = isna ( na_value ) if na_value_is_na : na_value = 1 result = lib . map_infer_mask ( arr , func , mask . view ( "uint8" ) , convert = False , na_value = na_value , dtype = np . dtype ( dtype ) , ) if not na_value_is_na : mask [ : ] = False return constructor ( result , mask ) elif is_string_dtype ( dtype ) and not is_object_dtype ( dtype ) : # i.e. StringDtype result = lib . map_infer_mask ( arr , func , mask . view ( "uint8" ) , convert = False , na_value = na_value ) return StringArray ( result ) else : # This is when the result type is object. We reach this when # -> We know the result type is truly object (e.g. .encode returns bytes #    or .findall returns a list). # -> We don't know the result type. E.g. `.get` can return anything. return lib . map_infer_mask ( arr , func , mask . view ( "uint8" ) )