title: pyspark 'DataFrame' object has no attribute '_get_object_id'
body: <p>I am trying to run some code, but getting error:</p>
  
  <blockquote>
    <p>'DataFrame' object has no attribute '_get_object_id'</p>
  </blockquote>
  
  <p>The code:</p>
  
  <pre><code>items = [(1,12),(1,float('Nan')),(1,14),(1,10),(2,22),(2,20),(2,float('Nan')),(3,300),
           (3,float('Nan'))]
  
  sc = spark.sparkContext
  rdd = sc.parallelize(items)
  df = rdd.toDF(["id", "col1"])
  
  import pyspark.sql.functions as func
  means = df.groupby("id").agg(func.mean("col1"))
  
  # The error is thrown at this line
  df = df.withColumn("col1", func.when((df["col1"].isNull()), means.where(func.col("id")==df["id"])).otherwise(func.col("col1"))) 
  </code></pre>