Lets have a df1 of even one column “col1”, lets values in it be e.g. [1, 1, 1, 5, 3, 2].
So the minimum value of col1 is 1, whe can find that e.g. by using min() func.
But how to get from df only rows which values in col1 are equal to that min value?
Well I’ve solved it by this:
min_value = df.select(min("col1")).collect()[0][0] # get min value
df = df.filter((col("col1") == min_value))
But I guess there should be more suitable way.
1
As @Derek indicated, the answer you have is optimal. But, you can use order by and attempt to fetch the first value if you are looking for a workaround.
sorted_df = df.orderBy("col1")
first_row_value = sorted_df.first()[0]
filtered_df = sorted_df.filter(F.col("col1") == first_row_value)