title: Pandas: filling missing values by mean in each group
body: <p>This should be straightforward, but the closest thing I've found is this post:
  <a href="https://stackoverflow.com/questions/18265930/pandas-filling-missing-values-within-a-group">pandas: Filling missing values within a group</a>, and I still can't solve my problem....</p>
  
  <p>Suppose I have the following dataframe</p>
  
  <pre><code>df = pd.DataFrame({'value': [1, np.nan, np.nan, 2, 3, 1, 3, np.nan, 3], 'name': ['A','A', 'B','B','B','B', 'C','C','C']})
  
    name  value
  0    A      1
  1    A    NaN
  2    B    NaN
  3    B      2
  4    B      3
  5    B      1
  6    C      3
  7    C    NaN
  8    C      3
  </code></pre>
  
  <p>and I'd like to fill in "NaN" with mean value in each "name" group, i.e.</p>
  
  <pre><code>      name  value
  0    A      1
  1    A      1
  2    B      2
  3    B      2
  4    B      3
  5    B      1
  6    C      3
  7    C      3
  8    C      3
  </code></pre>
  
  <p>I'm not sure where to go after:</p>
  
  <pre><code>grouped = df.groupby('name').mean()
  </code></pre>
  
  <p>Thanks a bunch.</p>