title: Replace NULL and blank values in all Data Frame columns with the most frequent Non Null item of the respective columns
body: <p>I am a novice to Python - I am trying to replace NULL and blank ('') values occurring in a column of a Pandas data frame with the most frequent item in that column. But I need to be able to do it for all columns and all rows of the data frame. I have written the following code - But it takes a lot of time to execute. Can you please help me optimize?</p>
  
  <p>Thanks
  Saptarshi</p>
  
  <pre><code>for column in df:
    #Get the value and frequency from the column
    tempDict = df[column].value_counts().to_dict()
  
    #pop the entries for 'NULL' and '?'
    tempDict.pop(b'NULL',None)
    tempDict.pop(b'?',None)
  
    #identify the max item of the remaining set
    maxItem = max(tempDict)
  
    #The next step is to replace all rows where '?' or 'null' appears with maxItem
    #df_test[column] = df_test[column].str.replace(b'NULL', maxItem)
    #df_test[column] = df_test[column].str.replace(b'?', maxItem)
    df[column][df[column] == b'NULL'] = maxItem
    df[column][df[column] == b'?'] = maxItem
  </code></pre>