Skip to content

Instantly share code, notes, and snippets.

@ajayborra
Last active November 5, 2018 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajayborra/cfff92d6e96e1e10a8c364dc5f7ac2c7 to your computer and use it in GitHub Desktop.
Save ajayborra/cfff92d6e96e1e10a8c364dc5f7ac2c7 to your computer and use it in GitHub Desktop.
Casting datatypes
// cast all the strings to Double type in Data Frame
val castedDF = df.columns.foldLeft(df)((current, c) =>
current.withColumn(c, current(c).cast(DoubleType)))
castedDF.describe().show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment