Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-19454

Improve DataFrame.replace API

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5.0, 1.6.0, 2.0.0, 2.1.0, 2.2.0
    • 2.2.0
    • PySpark, SQL
    • None

    Description

      Current implementation suffers from following issues:

      • It is possible to use dict as to_replace, but we cannot skip or use None as the value value (although it is ignored). This requires passing "magic" values:
        df = sc.parallelize([("Alice", 1, 3.0)]).toDF()
        df.replace({"Alice": "Bob"}, 1)
        
      • Code doesn't check if provided types are correct. This can lead to exception in Py4j (harder to diagnose):
         df.replace({"Alice": 1}, 1)
        

        or silent failures (with bundled Py4j version):

         df.replace({1: 2, 3.0: 4.1, "a": "b"}, 1)
        

      Attachments

        Issue Links

          Activity

            People

              zero323 Maciej Szymkiewicz
              zero323 Maciej Szymkiewicz
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: