title: Python/Pandas Dataframe replace 0 with median value
body: <p>I have a python pandas dataframe with several columns and one column has <code>0</code> values. I want to replace the <code>0</code> values with the <code>median</code> or <code>mean</code> of this column. </p>
  
  <p><code>data</code> is my dataframe<br>
  <code>artist_hotness</code> is the column</p>
  
  <pre><code>mean_artist_hotness = data['artist_hotness'].dropna().mean()
  
  if len(data.artist_hotness[ data.artist_hotness.isnull() ]) &gt; 0:
  data.artist_hotness.loc[ (data.artist_hotness.isnull()), 'artist_hotness'] = mean_artist_hotness
  </code></pre>
  
  <p>I tried this, but it is not working. </p>