Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Sort the column in ascending order with null values appearing first.
Syntax
asc_nulls_first()
Returns
Column
Examples
from pyspark.sql import Row
df = spark.createDataFrame(
[('Tom', 80), (None, 60), ('Alice', None)], ["name", "height"])
df.select(df.name).orderBy(df.name.asc_nulls_first()).collect()
# [Row(name=None), Row(name='Alice'), Row(name='Tom')]