Exemple #1
0
        /// <summary>
        /// Returns a new DataFrame by sampling a fraction of rows.
        /// </summary>
        /// <param name="withReplacement"> Sample with replacement or not. </param>
        /// <param name="fraction"> Fraction of rows to generate. </param>
        /// <param name="seed"> Seed for sampling. If it is not present, a randome long value will be assigned. </param>
        // Python API: https://github.com/apache/spark/blob/branch-1.4/python/pyspark/sql/dataframe.py
        // sample(self, withReplacement, fraction, seed=None)
        public DataFrame Sample(bool withReplacement, double fraction, long?seed)
        {
            long v;

            if (seed.HasValue)
            {
                v = seed.Value;
            }
            else
            {
                v = ((long)random.Next()) << 32 + random.Next();
            }
            return(new DataFrame(dataFrameProxy.Sample(withReplacement, fraction, v), sparkContext));
        }