Charts and the handoff to BI

Charts in the notebook serve two purposes. They are your smoke test that the mart is shaped right, and they are the reference image a BI developer compares against. If Tableau and your notebook disagree on a line, the mart is fine and the BI logic has drifted. That is a cheap, fast way to catch dashboard bugs.

data_engineering.ipynb
python
import matplotlib.pyplot as plt

weekly = con.sql('SELECT * FROM mart_weekly_reporters ORDER BY week_start').df()

fig, ax = plt.subplots(figsize=(10, 4))
ax.plot(weekly['week_start'], weekly['weekly_active_reporters'])
ax.set_title('Weekly active reporters')
ax.set_xlabel('week')
ax.set_ylabel('distinct reporters')
fig.tight_layout()
fig.savefig('out/charts/01_weekly_active_reporters.png', dpi=150)

Read the weekly-active-reporters mart back into pandas and plot it. Same SQL the BI tool will use, same numbers on the y axis.

Probably Tableau, if both read the mart. The mart is the contract. If Tableau is above the mart, something in the workbook is counting rows twice, often a join that fans out. Ask the BI person to show you their SQL, point at the mart row count, and debug from there. That conversation is much shorter than "whose pandas is right".

AI prompt: Try it: port your notebook to Postgres

Loading practice…

Quiz: Quiz

Loading practice…

Checkpoint: Final checkpoint: you own the medallion pattern

Loading practice…