code: def test_apply_mutate_columns(df):
      xx = np.arange(0, 5)
      hats = []
  
      def polyfit(df):
          fit = np.polyfit(df["x"], df["y"], 1)
          hat = np.polyval(fit, xx)
          hats.append(hat)
          return pd.DataFrame(dict(x=xx, y=hat))
  
      res = GroupBy(["a"]).apply(df, polyfit)
      assert_array_equal(res.index, np.arange(xx.size * 2))
      assert_array_equal(res.columns, ["a", "x", "y"])
      assert_array_equal(res["a"], ["a"] * xx.size + ["b"] * xx.size)
      assert_array_equal(res["x"], xx.tolist() + xx.tolist())
      assert_array_equal(res["y"], np.concatenate(hats))
  
file_path: seaborn/tests/_core/test_groupby.py
imports: import numpy
  import pandas
  import pytest
  from numpy.testing import assert_array_equal
  from seaborn._core.groupby import GroupBy
label_desc: Use image node_id 11 for calling a global function with example usage: test_apply_mutate_columns(df) and returns: pd