Skip to content

Commit 65dfb79

Browse files
committed
Add comment
1 parent b87ad0f commit 65dfb79

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Sources/SparkConnect/DataFrame.swift

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,23 +297,45 @@ public actor DataFrame: Sendable {
297297
return DataFrame(spark: self.spark, plan: SparkConnectClient.getLimit(self.plan.root, n))
298298
}
299299

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.
300306
public func sample(_ withReplacement: Bool, _ fraction: Double, _ seed: Int64) -> DataFrame {
301307
return DataFrame(spark: self.spark, plan: SparkConnectClient.getSample(self.plan.root, withReplacement, fraction, seed))
302308
}
303309

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.
304316
public func sample(_ withReplacement: Bool, _ fraction: Double) -> DataFrame {
305317
return sample(withReplacement, fraction, Int64.random(in: Int64.min...Int64.max))
306318
}
307319

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.
308326
public func sample(_ fraction: Double, _ seed: Int64) -> DataFrame {
309327
return sample(false, fraction, seed)
310328
}
311329

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.
312335
public func sample(_ fraction: Double) -> DataFrame {
313336
return sample(false, fraction)
314337
}
315338

316-
317339
/// Returns the first `n` rows.
318340
/// - Parameter n: The number of rows. (default: 1)
319341
/// - Returns: ``[[String?]]``

0 commit comments

Comments
 (0)