class_docstr: A collection of data which can be pre-processed in parallel on Spark
class_docstr_tok: ["A","collection","of","data","which","can","be","pre-processed","in","parallel","on","Spark"]
docstr: Return a new SparkXShards by applying a function to each shard of this SparkXShards
  
  :param func: python function to process data. The first argument is the data shard.
  :param args: other arguments in this function.
  :return: a new SparkXShards.
docstr_tok: ["Return","a","new","SparkXShards","by","applying","a","function","to","each","shard","of","this","SparkXShards",":","param","func",":","python","function","to","process","data",".","The","first","argument","is","the","data","shard",".",":","param","args",":","other","arguments","in","this","function",".",":","return",":","a","new","SparkXShards","."]
code: def transform_shard(self, func, *args):
      """
  
      Return a new SparkXShards by applying a function to each shard of this SparkXShards
  
      :param func: python function to process data. The first argument is the data shard.
      :param args: other arguments in this function.
      :return: a new SparkXShards.
      """
  
      def transform(iter, func, *args):
          for x in iter:
              yield func(x, *args)
  
      transformed_shard = SparkXShards(
          self.rdd.mapPartitions(
              lambda iter: transform(iter, func, *args)
          )
      )
      self._uncache()
      return transformed_shard
  
imports: from py4j.protocol import Py4JError
  from zoo.orca.data.utils import *
  from zoo.orca import OrcaContext
  from zoo.common.nncontext import init_nncontext
  from zoo import ZooContext, get_node_and_core_number
  from zoo.util import nest
label_desc: Use image node_id 2 for calling the SparkXShards obj's underlying member method code with example usage: obj.transform_shard(func) and returns: transformed_shard