pyspark.sql.Column.asc_nulls_last

Column.asc_nulls_last() → pyspark.sql.column.Column

Returns a sort expression based on ascending order of the column, and null values appear after non-null values.

New in version 2.4.0.

Changed in version 3.4.0: Supports Spark Connect.

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_last()).collect()
[Row(name='Alice'), Row(name='Tom'), Row(name=None)]