code: def test_complete_groupby():
      """Test output in the presence of a groupby."""
      df = pd.DataFrame(
          {
              "state": ["CA", "CA", "HI", "HI", "HI", "NY", "NY"],
              "year": [2010, 2013, 2010, 2012, 2016, 2009, 2013],
              "value": [1, 3, 1, 2, 3, 2, 5],
          }
      )
  
      result = df.complete(
          {"year": lambda x: range(x.year.min(), x.year.max() + 1)},
          by="state",
          sort=True,
      )
  
      expected = (
          df.set_index("year")
          .groupby("state")
          .apply(
              lambda x: x.reindex(
                  range(x.index.min(), x.index.max() + 1)
              )
          )
          .drop(columns="state")
          .reset_index()
      )
  
      assert_frame_equal(result, expected)
  
imports: from string import ascii_lowercase
  import numpy
  import pandas
  import pytest
  from hypothesis import given, settings
  from pandas.testing import assert_frame_equal
  from janitor.testing_utils.strategies import categoricaldf_strategy
label_desc: Use image node_id 32 for calling a global function with example usage: test_complete_groupby() without return types