title: Replace A Column Value by Most Frequent Value In Group
body: <p>I have the following dataframe:</p>
  <pre><code>df = pd.DataFrame({'student': list('AAABBBCCCC'),
                     'city': ['LA', 'LA', 'NY', 'DC', 'NY', 'NY', 'SF', 'SF', 'LA', 'SF'],
                     'score': [75, 27, 31, 22, 43, 20, 26, 40, 33, 20]})
  
  print(df)
  
    student city  score
  0       A   LA     75
  1       A   LA     27
  2       A   NY     31
  3       B   DC     22
  4       B   NY     43
  5       B   NY     20
  6       C   SF     26
  7       C   SF     40
  8       C   LA     33
  9       C   SF     20
  </code></pre>
  <p>I have to replace the <code>city</code> column based on which city appears most for that student. For example, here is the <code>value_counts()</code> of the city for each student:</p>
  <pre><code>df.groupby('student').city.value_counts()
  
  student  city
  A        LA      2
           NY      1
  B        NY      2
           DC      1
  C        SF      3
           LA      1
  </code></pre>
  <p>We can see, for the student <code>A</code>, <code>LA</code> appears most of the time. Hence, we want to replace other cities (here <code>NY</code>) with <code>LA</code>.</p>
  <p><strong>Desired output</strong>:</p>
  <pre><code>  student city  score
  0       A   LA     75
  1       A   LA     27
  2       A   LA     31
  3       B   NY     22
  4       B   NY     43
  5       B   NY     20
  6       C   SF     26
  7       C   SF     40
  8       C   SF     33
  9       C   SF     20
  
  </code></pre>
  <p>What would be the ideal way of getting the desired output? Any suggestions would be appreciated. Thanks!</p>