# 9.8:  Use .stack() and .unstack() (with .groupby()).  Looking at the above example, note that
# .groupby() produces results in "long" format, while .pivot_table() renders them in "wide" format.
# Use .unstack() and .stack() to move between the two.

import pandas as pd
import numpy as np

df = pd.read_excel("../sales-funnel.xlsx")

dfgb = df.groupby(['SalesRep', 'Product'])[['SaleAmount', 'Quantity']].sum()

dfgb

dfgbus = dfgb.unstack()

dfgbus

dfgbus.stack()

dfgbus

