Skip to content

Instantly share code, notes, and snippets.

@yvan
Last active February 22, 2023 23:37
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 yvan/9bb461d4ee1dae612af4ccdcbb5494c7 to your computer and use it in GitHub Desktop.
Save yvan/9bb461d4ee1dae612af4ccdcbb5494c7 to your computer and use it in GitHub Desktop.
# pandas
df[col2] = np.where(df[col2] == 1, True, False)
# pyspark
df = df.withColumn(col2, F.when(F.col(col2) == 1, True).otherwise(False))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment