Sandbox — pandas & charts
This page is a lab, not a student chapter. It checks three ways to “chart” on Piston:
- Pandas tables (already fast)
- ASCII bars (testable, no image)
- matplotlib PNG (needs longer CPU time + a
PISTON_PNG:line) - seaborn (same PNG trick; seaborn sits on matplotlib)
Run with batch mode (interactive off) so the full PNG arrives in one response.
Print a PNG like this:
print("PISTON_PNG:" + base64.b64encode(png_bytes).decode("ascii"))
The runner hides that line and shows the image.
1. Pandas table
2. ASCII bar chart
Graded exams can check this output. No matplotlib.
3. matplotlib PNG
Uses Agg (no window). First import is slow; Piston CPU/time was raised for this.
If this is killed (Time limit exceeded), restart Piston after the compose change:
cd /Users/nenewang/Documents/GIT/piston
docker compose up -d api
Limits in docker-compose.yaml: PISTON_RUN_TIMEOUT=20000, PISTON_RUN_CPU_TIME=15000, PISTON_OUTPUT_MAX_SIZE=250000.
4. seaborn PNG
Same Agg backend. sns.set_theme() then a barplot.