title: pyspark taking a log of column
body: <pre><code>length = df.count()
  df = df.withColumn("log", log(col("power"),lit(length)))
  </code></pre>
  
  <p>The following lines throw such an error. Can you please help me take a log of a column using another value or another column as a base.</p>
  
  <hr>
  
  <pre><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-102-c0894b6127d1&gt; in &lt;module&gt;()
        1 #df.show()
        2 
  ----&gt; 3 df = df.withColumn("log", log(col("power"),lit(2)))
  
  5 frames
  /content/spark-2.4.5-bin-hadoop2.7/python/pyspark/sql/column.py in __iter__(self)
      342 
      343     def __iter__(self):
  --&gt; 344         raise TypeError("Column is not iterable")
      345 
      346     # string methods
  
  TypeError: Column is not iterable
  </code></pre>