parameters: (builder, source_array, encoding_info)
return_statement: return (array_type, array_value)
docstring: Serialize any of the various typed arrays, eg, Float32Array. Specific means of serialization and type conversion
      are provided by type_info.
docstring_summary: Serialize any of the various typed arrays, eg, Float32Array. Specific means of serialization and type conversion
      are provided by type_info.
docstring_tokens: Serialize any of the various typed arrays eg Float32Array . Specific means of serialization and type conversion are provided by type_info .
function: def serialize_typed_array(builder, source_array, encoding_info):
      """
      Serialize any of the various typed arrays, eg, Float32Array. Specific means of serialization and type conversion
      are provided by type_info.
      """
  
      arr = source_array
      (array_type, as_type) = encoding_info(source_array)
  
      if isinstance(arr, pd.Index):
          arr = arr.to_series()
  
      # convert to a simple ndarray
      if as_type == "json":
          as_json = arr.to_json(orient="records")
          arr = np.array(bytearray(as_json, "utf-8"))
      else:
          if sparse.issparse(arr):
              arr = arr.toarray()
          elif isinstance(arr, pd.Series):
              arr = arr.to_numpy()
          if arr.dtype != as_type:
              arr = arr.astype(as_type)
  
      # serialize the ndarray into a vector
      if arr.ndim == 2:
          if arr.shape[0] == 1:
              arr = arr[0]
          elif arr.shape[1] == 1:
              arr = arr.T[0]
  
      vec = builder.CreateNumpyVector(arr)
  
      # serialize the typed array table
      builder.StartObject(1)
      builder.PrependUOffsetTRelativeSlot(0, vec, 0)
      array_value = builder.EndObject()
      return (array_type, array_value)
function_tokens: def serialize_typed_array ( builder , source_array , encoding_info ) : arr = source_array ( array_type , as_type ) = encoding_info ( source_array ) if isinstance ( arr , pd . Index ) : arr = arr . to_series ( ) # convert to a simple ndarray if as_type == "json" : as_json = arr . to_json ( orient = "records" ) arr = np . array ( bytearray ( as_json , "utf-8" ) ) else : if sparse . issparse ( arr ) : arr = arr . toarray ( ) elif isinstance ( arr , pd . Series ) : arr = arr . to_numpy ( ) if arr . dtype != as_type : arr = arr . astype ( as_type ) # serialize the ndarray into a vector if arr . ndim == 2 : if arr . shape [ 0 ] == 1 : arr = arr [ 0 ] elif arr . shape [ 1 ] == 1 : arr = arr . T [ 0 ] vec = builder . CreateNumpyVector ( arr ) # serialize the typed array table builder . StartObject ( 1 ) builder . PrependUOffsetTRelativeSlot ( 0 , vec , 0 ) array_value = builder . EndObject ( ) return ( array_type , array_value )