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: Samples from each pandas dataframe in old SparkXShards, Return a new SparkXShards  .
  
  :param frac: float,  Fraction of items to return.
  :param replace: bool, default False,
      Allow or disallow sampling of the same row more than once.
  :param weights: str or ndarray-like, optional
      Default 'None' results in equal probability weighting.
  :param random_state: int, array-like, BitGenerator, np.random.RandomState, optional
      If int, array-like, or BitGenerator (NumPy>=1.17), seed for
      random number generator
      If np.random.RandomState, use as numpy RandomState object.
  :return: a new SparkXShards.
docstr_tok: ["Samples","from","each","pandas","dataframe","in","old","SparkXShards",",","Return","a","new","SparkXShards",".",":","param","frac",":","float",",","Fraction","of","items","to","return",".",":","param","replace",":","bool",",","default","False",",","Allow","or","disallow","sampling","of","the","same","row","more","than","once",".",":","param","weights",":","str","or","ndarray-like",",","optional","Default","'None","'","results","in","equal","probability","weighting",".",":","param","random_state",":","int",",","array-like",",","BitGenerator",",","np.random.RandomState",",","optional","If","int",",","array-like",",","or","BitGenerator","(","NumPy",">","=1.17",")",",","seed","for","random","number","generator","If","np.random.RandomState",",","use","as","numpy","RandomState","object",".",":","return",":","a","new","SparkXShards","."]
code: def sample(
      self,
      frac: float,
      replace: bool = False,
      weights=None,
      random_state=None,
  ) -> "SparkXShards":
      """
      Samples from each pandas dataframe in old SparkXShards, Return a new SparkXShards  .
  
      :param frac: float,  Fraction of items to return.
      :param replace: bool, default False,
          Allow or disallow sampling of the same row more than once.
      :param weights: str or ndarray-like, optional
          Default 'None' results in equal probability weighting.
      :param random_state: int, array-like, BitGenerator, np.random.RandomState, optional
          If int, array-like, or BitGenerator (NumPy>=1.17), seed for
          random number generator
          If np.random.RandomState, use as numpy RandomState object.
      :return: a new SparkXShards.
      """
      if self._get_class_name() != "pandas.core.frame.DataFrame":
          invalidInputError(
              False,
              "Currently only support sample() on"
              " SparkXShards of Pandas DataFrame",
          )
  
      def inner_sample(
          iter, frac, replace=False, weights=None, random_state=None
      ):
          for df in iter:
              yield df.sample(
                  frac=frac,
                  replace=replace,
                  weights=weights,
                  random_state=random_state,
              )
  
      rdd1 = self.rdd.mapPartitions(
          lambda iter: inner_sample(
              iter, frac, replace, weights, random_state
          )
      )
      return SparkXShards(rdd1)
  
imports: from py4j.protocol import Py4JError
  from bigdl.orca.data.utils import *
  from bigdl.orca import OrcaContext
  from bigdl.dllib.utils.common import get_node_and_core_number, get_spark_sql_context, get_spark_context
  from bigdl.dllib.utils import nest
  from bigdl.dllib.utils.log4Error import invalidInputError
  import numpy
  from typing import TYPE_CHECKING, Any
  from typing import Callable, Dict, List, Optional, Tuple, Union
label_desc: Use image node_id 40 for calling the SparkXShards obj's underlying member method code with example usage: obj.sample(frac, replace, weights, random_state) and returns: SparkXShards