Have you ever wondered how to create a pivot table in Python? It is actually very easy with Pandas.

Here is the code that appeared in the video.

import pandas as pd
import numpy as np


pd.__version__
np.__version__

data = pd.read_excel("patients.xlsx")

data_pivot = pd.pivot_table(data, values="Height", index="Gender", columns="Location", aggfunc=np.average, margins=True)