def METHOD_NAME():
    x = np.random.standard_normal((3, 7, 100))
    df = panel_to_frame(x, list(range(3)), list(range(7)), list(range(100)))
    mi = pd.MultiIndex.from_product([list(range(7)), list(range(100))])
    expected = pd.DataFrame(index=mi, columns=[0, 1, 2])
    for i in range(3):
        expected[i] = x[i].ravel()
    expected.index.names = ["major", "minor"]
    pd.testing.assert_frame_equal(df, expected)
    expected2 = expected.copy()
    expected2 = expected2.sort_index(level=[1, 0])
    expected2.index = expected2.index.swaplevel(0, 1)
    expected2.index.names = ["major", "minor"]
    df2 = panel_to_frame(x, list(range(3)), list(range(7)), list(range(100)), True)
    pd.testing.assert_frame_equal(df2, expected2)
    entities = list(
        map(
            "".join,
            [
                [random.choice(string.ascii_lowercase) for __ in range(10)]
                for _ in range(100)
            ],
        )
    )
    times = pd.date_range("1999-12-31", freq="A-DEC", periods=7)
    var_names = [f"x.{i}" for i in range(1, 4)]
    df3 = panel_to_frame(x, var_names, times, entities, True)
    mi = pd.MultiIndex.from_product([times, entities])
    expected3 = pd.DataFrame(index=mi, columns=var_names)
    for i in range(1, 4):
        expected3[f"x.{i}"] = x[i - 1].ravel()
    expected3.index = expected3.index.swaplevel(0, 1)
    mi = pd.MultiIndex.from_product([entities, times])
    expected3 = expected3.loc[mi]
    expected3.index.names = ["major", "minor"]
    pd.testing.assert_frame_equal(df3, expected3)