title: how to replace infinite value with maximum value of a pandas column?
body: <p>I have a dataframe which looks like </p>
  
  <pre><code>City   Crime_Rate
  
  A      10
  
  B      20 
  
  C      inf
  
  D      15 
  </code></pre>
  
  <p>I want to replace the inf with the max value of the Crime_Rate column , so that my resulting dataframe should look like</p>
  
  <pre><code>City   Crime_Rate
  
  A      10
  
  B      20 
  
  C      20
  
  D      15
  </code></pre>
  
  <p>I tried </p>
  
  <pre><code>df['Crime_Rate'].replace([np.inf],max(df['Crime_Rate']),inplace=True)
  </code></pre>
  
  <p>But python takes inf as the maximum value , where am I going wrong here ? </p>