df = pd.read_excel('../data/02. sales-funnel.xlsx')
df.head()

# Name 컬럼을 인덱스로 설정
# pd.pivot_table(df, index='Name')
df.pivot_table(index='Name') # 수치형 데이터만 value로 남음

df.pivot_table(index=['Manager', 'Rep'], values="Price") # Price의 평균으로 반환(default)

df.pivot_table(index=['Manager', 'Rep'], values="Price", aggfunc=np.sum)

# 특정열 컬럼으로 지정
df.pivot_table(index=['Manager', 'Rep'], values="Price", columns="Product", aggfunc=np.sum)
# Nan 값 설정 : fill_value
df.pivot_table(index=['Manager', 'Rep'], values="Price", columns="Product", aggfunc=np.sum, fill_value=0)

df.pivot_table(index=['Manager', 'Rep', 'Product'], values=["Price", 'Quantity'], aggfunc=np.sum, fill_value=0)

df.pivot_table(
index=['Manager', 'Rep', 'Product'],
values=["Price", 'Quantity'],
aggfunc=[np.sum, np.mean],
fill_value=0,
margins=True) # 총계(All) 값 추가
