title: Replace Null values of a column with its average in a Spark DataFrame
body: <p>Is there any function in Spark which can calculate the mean of a column in a DataFrame by ignoring null/NaN? Like in R, we can pass an option such as na.rm=TRUE.</p>
  
  <p>When I apply avg() on a column with a NaN, I get NaN only.</p>