Skip to content

Instantly share code, notes, and snippets.

@rssanders3
Last active January 28, 2019 17:45
Show Gist options
  • Select an option

  • Save rssanders3/b6eb7e61142bf806de3fd06bf27aba0e to your computer and use it in GitHub Desktop.

Select an option

Save rssanders3/b6eb7e61142bf806de3fd06bf27aba0e to your computer and use it in GitHub Desktop.
import org.apache.spark.sql.functions._
val allegiancesCleanupUDF = udf[String, String] (_.toLowerCase().replace("house ", ""))
val isDeathUDF = udf{ deathYear: Integer => if(deathYear != null) 1 else 0}
val gotCleaned = got.filter("Allegiances != \"None\"").withColumn("Allegiances", allegiancesCleanupUDF($"Allegiances")).withColumn("isDeath", isDeathUDF($"Death Year"))
display(gotCleaned)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment