Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5282#discussion_r27457733
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/DataFrameNaFunctions.scala ---
    @@ -189,6 +189,128 @@ final class DataFrameNaFunctions private[sql](df: 
DataFrame) {
        */
       def fill(valueMap: Map[String, Any]): DataFrame = fill0(valueMap.toSeq)
     
    +  /**
    +   * Replaces values matching keys in `replacement` map with the 
corresponding values.
    +   * Key and value of `replacement` map must have the same type, and can 
only be doubles or strings.
    +   * If `col` is "*", then the replacement is applied on all string 
columns or numeric columns.
    +   *
    +   * {{{
    +   *   import com.google.common.collect.ImmutableMap;
    +   *
    +   *   // Replaces all occurrences of 1.0 with 2.0 in column "height".
    +   *   df.replace("height", ImmutableMap.of(1.0, 2.0));
    +   *
    +   *   // Replaces all occurrences of "UNKNOWN" with "unnamed" in column 
"name".
    +   *   df.replace("name", ImmutableMap.of("UNKNOWN", "unnamed"));
    +   *
    +   *   // Replaces all occurrences of "UNKNOWN" with "unnamed" in all 
string columns.
    +   *   df.replace("*", ImmutableMap.of("UNKNOWN", "unnamed"));
    +   * }}}
    +   *
    +   * @param col name of the column to apply the value replacement
    +   * @param replacement value replacement map, as explained above
    +   */
    +  def replace[T](col: String, replacement: java.util.Map[T, T]): DataFrame 
= {
    +    replace[T](col, replacement.toMap : Map[T, T])
    +  }
    +
    +  /**
    +   * Replaces values matching keys in `replacement` map with the 
corresponding values.
    +   * Key and value of `replacement` map must have the same type, and can 
only be doubles or strings.
    +   *
    +   * {{{
    +   *   import com.google.common.collect.ImmutableMap;
    +   *
    +   *   // Replaces all occurrences of 1.0 with 2.0 in column "height" and 
"weight".
    +   *   df.replace(new String[] {"height", "weight"}, ImmutableMap.of(1.0, 
2.0));
    +   *
    +   *   // Replaces all occurrences of "UNKNOWN" with "unnamed" in column 
"firstname" and "lastname".
    +   *   df.replace(new String[] {"firstname", "lastname"}, 
ImmutableMap.of("UNKNOWN", "unnamed"));
    +   * }}}
    +   *
    +   * @param col list of columns to apply the value replacement
    +   * @param replacement value replacement map, as explained above
    +   */
    +  def replace[T](col: Array[String], replacement: java.util.Map[T, T]): 
DataFrame = {
    --- End diff --
    
    `col` -> `cols`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to