Skip to content

Instantly share code, notes, and snippets.

@jph00
jph00 / py_stdlib.md
Last active September 22, 2022 18:30
Hyperlinked index to every module, function, and class in the Python standard library

All of the python 3.9 standard library

(Too big for a single gist, so see first reply for the rest)

Table of contents

@zoltanctoth
zoltanctoth / pyspark-udf.py
Last active July 15, 2023 13:23
Writing an UDF for withColumn in PySpark
from pyspark.sql.types import StringType
from pyspark.sql.functions import udf
maturity_udf = udf(lambda age: "adult" if age >=18 else "child", StringType())
df = spark.createDataFrame([{'name': 'Alice', 'age': 1}])
df.withColumn("maturity", maturity_udf(df.age))
df.show()