#1 Put the Python formula in A1
=PY("import pandas as pd, numpy as np;
df = pd.DataFrame(np.random.randint(0,3,(3,3)), columns=list('ABC'), index=[1,2,3]);
df.reset_index(names='Index', inplace=True);
return df")
#2 Click the little ↘ icon (or choose **Excel values** in the dropdown)
The DataFrame now *spills* as a normal 4 × 4 grid (index + A B C).
#3 Give that spill a named range
Formulas ► Name Manager ► New →
Name: **DF_Out**
Refers to: `=Sheet1!$A$1#` ← the **#** means “this whole spill, whatever size”.
#4 Insert a PivotTable
Insert ► PivotTable ► *From Table/Range* → type **DF_Out**.
Build the Pivot, then add a PivotChart if you like.
✔ The pivot/chart updates whenever the Python code re-runs; just hit **Data ► Refresh All**.
Limitations
* A spill range itself can’t become an Excel Table (Excel blocks it), so the named-range trick is the workaround.
* If you really need a Table, copy-paste-values the spill elsewhere, press **Ctrl + T**, and use that – but you’ll have to overwrite it each time the DataFrame changes.