title: How to replace NA values with mode of a DataFrame column in python?
body: <p>I'm completely new to Python (and this website) and am currently trying to replace NA values in specific dataframe columns with their mode. I've tried various methods which are not working. Please help me spot what I'm doing incorrectly:</p>
  
  <p>Note: All the columns I'm working with are <code>float64</code> types. All my codes run but when I check the null amount with <code>df[cols_mode].isnull().sum()</code> in the columns, it remains the same.</p>
  
  <p><strong>Method 1:</strong></p>
  
  <pre><code>cols_mode = ['race', 'goal', 'date', 'go_out', 'career_c']
  
  df[cols_mode].apply(lambda x: x.fillna(x.mode, inplace=True))
  </code></pre>
  
  <p>I tried the Imputer method too but encountered the same result</p>
  
  <p><strong>Method 2:</strong> </p>
  
  <pre><code>for column in df[['race', 'goal', 'date', 'go_out', 'career_c']]:
      mode = df[column].mode()
      df[column] = df[column].fillna(mode)
  </code></pre>
  
  <p><strong>Method 3:</strong> </p>
  
  <pre><code>df['race'].fillna(df.race.mode(), inplace=True)
  df['goal'].fillna(df.goal.mode(), inplace=True)
  df['date'].fillna(df.date.mode(), inplace=True)
  df['go_out'].fillna(df.go_out.mode(), inplace=True)
  df['career_c'].fillna(df.career_c.mode(), inplace=True)
  </code></pre>
  
  <p><strong>Method 4:</strong>
  My methods become more and more of a manual process and finally this one works:</p>
  
  <pre><code>df['race'].fillna(2.0, inplace=True)
  df['goal'].fillna(1.0, inplace=True)
  df['date'].fillna(6.0, inplace=True)
  df['go_out'].fillna(2.0, inplace=True)
  df['career_c'].fillna(2.0, inplace=True) 
  </code></pre>