@@ -297,23 +297,45 @@ public actor DataFrame: Sendable {
297
297
return DataFrame ( spark: self . spark, plan: SparkConnectClient . getLimit ( self . plan. root, n) )
298
298
}
299
299
300
+ /// Returns a new ``Dataset`` by sampling a fraction of rows, using a user-supplied seed.
301
+ /// - Parameters:
302
+ /// - withReplacement: Sample with replacement or not.
303
+ /// - fraction: Fraction of rows to generate, range [0.0, 1.0].
304
+ /// - seed: Seed for sampling.
305
+ /// - Returns: A subset of the records.
300
306
public func sample( _ withReplacement: Bool , _ fraction: Double , _ seed: Int64 ) -> DataFrame {
301
307
return DataFrame ( spark: self . spark, plan: SparkConnectClient . getSample ( self . plan. root, withReplacement, fraction, seed) )
302
308
}
303
309
310
+ /// Returns a new ``Dataset`` by sampling a fraction of rows, using a random seed.
311
+ /// - Parameters:
312
+ /// - withReplacement: Sample with replacement or not.
313
+ /// - fraction: Fraction of rows to generate, range [0.0, 1.0].
314
+ /// - seed: Seed for sampling.
315
+ /// - Returns: A subset of the records.
304
316
public func sample( _ withReplacement: Bool , _ fraction: Double ) -> DataFrame {
305
317
return sample ( withReplacement, fraction, Int64 . random ( in: Int64 . min... Int64 . max) )
306
318
}
307
319
320
+ /// Returns a new ``Dataset`` by sampling a fraction of rows (without replacement), using a
321
+ /// user-supplied seed.
322
+ /// - Parameters:
323
+ /// - fraction: Fraction of rows to generate, range [0.0, 1.0].
324
+ /// - seed: Seed for sampling.
325
+ /// - Returns: A subset of the records.
308
326
public func sample( _ fraction: Double , _ seed: Int64 ) -> DataFrame {
309
327
return sample ( false , fraction, seed)
310
328
}
311
329
330
+ /// Returns a new ``Dataset`` by sampling a fraction of rows (without replacement), using a
331
+ /// random seed.
332
+ /// - Parameters:
333
+ /// - fraction: Fraction of rows to generate, range [0.0, 1.0].
334
+ /// - Returns: A subset of the records.
312
335
public func sample( _ fraction: Double ) -> DataFrame {
313
336
return sample ( false , fraction)
314
337
}
315
338
316
-
317
339
/// Returns the first `n` rows.
318
340
/// - Parameter n: The number of rows. (default: 1)
319
341
/// - Returns: ``[[String?]]``
0 commit comments