0

Inspired by the How to replace NaNs by preceding or next values in pandas DataFrame?

Is there a way to replace every None, empty or null value with the first non-empty value in the same column above it? If you have a dataframe like:

    0   1   2
0   1   2   3
1   4  None None
2 None None 9

to become like:

   0  1  2
0  1  2  3
1  4  2  3
2  4  2  9

Spark has pyspark.sql.DataFrame.fillna but option like (method='ffill') is not available.

Bor
  • 775
  • 3
  • 21
  • 41
  • 2
    Does this answer your question? [Pyspark : forward fill with last observation for a DataFrame](https://stackoverflow.com/questions/36019847/pyspark-forward-fill-with-last-observation-for-a-dataframe) – ddejohn Oct 22 '21 at 03:22

0 Answers0