title: Mean imputation based on certain Conditions
body: <p>I have the below dataframe,</p>
  <pre><code>Category    Value
  A           100
  A           -
  B           -
  C           50
  D           200
  D           400
  D           -
  </code></pre>
  <p>As you can see, there are some values which have the hyphen symbol '-'. I want to replace those hyphons with the means of the corresponding category.</p>
  <p>In the example, there are two entries for &quot;A&quot; - One row with value 100 and other with hyphen. So the mean would be 100 itself. For B, since there are no valid values, the mean would be the mean of the entire column which would be (100+50+200+400/4 = 187.5). For C, no changes and for D, the hyphen will be replaced by 300 (same logic as for &quot;A&quot;).</p>
  <p>Output:</p>
  <pre><code>Category    Value
  A           100
  A           100
  B           187.5
  C           50
  D           200
  D           400
  D           300
  </code></pre>