xl("A1") # single value
xl("A1:C5") # range → DataFrame (or Series if one col)
xl("A1:C5", headers=True) # treat first row as headers
xl("Sheet2!A1:C100") # range from another sheet
xl("MyTable[#All]") # an Excel Table by name
xl("MyTable[Revenue]") # one column of a Table
=PY(
tax_rate = xl("B1")
amount = xl("B2")
amount * (1 + tax_rate)
)
Best practice: lay your data out with headers in the first row, then read with headers=True:
=PY(
df = xl("A1:D100", headers=True)
df.groupby("Region")["Revenue"].sum()
)
=PY(
df = xl("RawData!A1:F1000", headers=True)
df.head()
)
If your data is a real Excel Table (Ctrl+T on a range), you can reference it by name. That's the most readable option and survives row insertions/deletions:
=PY(
sales = xl("SalesTable[#All]", headers=True)
sales["Total"] = sales["Qty"] * sales["Price"]
sales
)
Put this in A1:C5 (headers in row 1):
Region Quarter Revenue
North Q1 1200
North Q2 1500
South Q1 900
South Q2 1100
=PY(
df = xl("A1:C5", headers=True)
df.groupby("Region")["Revenue"].agg(["sum", "mean"])
)
Right-click → Output as → Excel values. You get a clean two-column summary.
=PY() cells purely for analysis and presentation. When new rows come in, the analysis updates automatically.
xl("A1:B5", headers=True) brings a labelled range in as a DataFrame.Sheet2!A1:B5 syntax.Lay out a list of 10 employees with a Sales column. In a =PY() cell, return the top three by sales as a DataFrame.