title: Pandas Groupby and Apply
body: <p>I am performing a grouby and apply over a dataframe that is returning some strange results, I am using pandas 1.3.1</p>
  <p>Here is the code:</p>
  <pre><code>ddf = pd.DataFrame({
      &quot;id&quot;: [1,1,1,1,2]
  })
  
  def do_something(df):
      return &quot;x&quot;
  
  ddf[&quot;title&quot;] = ddf.groupby(&quot;id&quot;).apply(do_something)
  ddf
  </code></pre>
  <p>I would expect every row in the <code>title</code> column to be assigned the value &quot;x&quot; but when this happens I get this data:</p>
  <pre><code>        id title
  0        1   NaN
  1        1     x
  2        1     x
  3        1   NaN
  4        2   NaN
  </code></pre>
  <p>Is this expected?</p>