You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (JIRA)" <ji...@apache.org> on 2018/09/20 17:14:00 UTC
[jira] [Resolved] (SPARK-25381) Stratified sampling by Column
argument
[ https://issues.apache.org/jira/browse/SPARK-25381?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Hyukjin Kwon resolved SPARK-25381.
----------------------------------
Resolution: Fixed
Fix Version/s: 2.5.0
Fixed in https://github.com/apache/spark/pull/22365
> Stratified sampling by Column argument
> --------------------------------------
>
> Key: SPARK-25381
> URL: https://issues.apache.org/jira/browse/SPARK-25381
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 2.4.0
> Reporter: Maxim Gekk
> Priority: Minor
> Fix For: 2.5.0
>
>
> Currently the sampleBy method accepts the first argument of string type only. Need to provide overloaded method which accepts Column type too. So, it will allow sampling by multiple columns , for example:
> {code:scala}
> import org.apache.spark.sql.Row
> import org.apache.spark.sql.functions.struct
> val df = spark.createDataFrame(Seq(("Bob", 17), ("Alice", 10), ("Nico", 8), ("Bob", 17),
> ("Alice", 10))).toDF("name", "age")
> val fractions = Map(Row("Alice", 10) -> 0.3, Row("Nico", 8) -> 1.0)
> df.stat.sampleBy(struct($"name", $"age"), fractions, 36L).show()
> +-----+---+
> | name|age|
> +-----+---+
> | Nico| 8|
> |Alice| 10|
> +-----+---+
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org