Skip to content

Instantly share code, notes, and snippets.

@1ambda
Created December 21, 2021 23:33
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 1ambda/0a44754cf77b1c6ad97b3816194757f0 to your computer and use it in GitHub Desktop.
Save 1ambda/0a44754cf77b1c6ad97b3816194757f0 to your computer and use it in GitHub Desktop.
dfJson = dfPrepared\
.where(col("category_code").isNotNull())\
.withColumn("category", to_json(struct(col("category_id"), col("category_code"))))\
dfJson.printSchema()
dfJson.show(truncate=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment