code: def test_filter_enforces_scalarness():
      df = DataFrame(
          [
              ["best", "a", "x"],
              ["worst", "b", "y"],
              ["best", "c", "x"],
              ["best", "d", "y"],
              ["worst", "d", "y"],
              ["worst", "d", "y"],
              ["best", "d", "z"],
          ],
          columns=["a", "b", "c"],
      )
      with pytest.raises(
          TypeError, match="filter function returned a.*"
      ):
          df.groupby("c").filter(lambda g: g["a"] == "best")
  
imports: from string import ascii_lowercase
  import numpy
  import pytest
  import pandas
  from pandas import DataFrame, Series, Timestamp
  import pandas._testing
label_desc: Use image node_id 25 for calling a global function with example usage: test_filter_enforces_scalarness() without return types