code: def test_flat_should_drop_index_level():
      index = pd.to_datetime(["2021-01-01", "2021-01-02", "2021-01-03"])
      index.name = "__timestamp"
      columns = pd.MultiIndex.from_arrays(
          [["a"] * 3, ["b"] * 3, ["c", "d", "e"], ["ff", "ii", "gg"]],
          names=["level1", "level2", "level3", "level4"],
      )
      df = pd.DataFrame(index=index, columns=columns, data=1)
  
      # drop level by index
      assert pp.flatten(
          df.copy(),
          drop_levels=(
              0,
              1,
          ),
      ).equals(
          pd.DataFrame(
              {
                  "__timestamp": index,
                  FLAT_COLUMN_SEPARATOR.join(["c", "ff"]): [1, 1, 1],
                  FLAT_COLUMN_SEPARATOR.join(["d", "ii"]): [1, 1, 1],
                  FLAT_COLUMN_SEPARATOR.join(["e", "gg"]): [1, 1, 1],
              }
          )
      )
  
      # drop level by name
      assert pp.flatten(
          df.copy(), drop_levels=("level1", "level2")
      ).equals(
          pd.DataFrame(
              {
                  "__timestamp": index,
                  FLAT_COLUMN_SEPARATOR.join(["c", "ff"]): [1, 1, 1],
                  FLAT_COLUMN_SEPARATOR.join(["d", "ii"]): [1, 1, 1],
                  FLAT_COLUMN_SEPARATOR.join(["e", "gg"]): [1, 1, 1],
              }
          )
      )
  
      # only leave 1 level
      assert pp.flatten(df.copy(), drop_levels=(0, 1, 2)).equals(
          pd.DataFrame(
              {
                  "__timestamp": index,
                  FLAT_COLUMN_SEPARATOR.join(["ff"]): [1, 1, 1],
                  FLAT_COLUMN_SEPARATOR.join(["ii"]): [1, 1, 1],
                  FLAT_COLUMN_SEPARATOR.join(["gg"]): [1, 1, 1],
              }
          )
      )
  
file_path: superset/tests/unit_tests/pandas_postprocessing/test_flatten.py
imports: import pandas
  from superset.utils import pandas_postprocessing
  from superset.utils.pandas_postprocessing.utils import FLAT_COLUMN_SEPARATOR
  from tests.unit_tests.fixtures.dataframes import timeseries_df
label_desc: Use image node_id 5 for calling a global function with example usage: test_flat_should_drop_index_level() without return types