Skip to content

UmdTask751_MSML610_Fall2026_Polars_Pandas_vs_Polars_Benchmark_on_Crypto_Trade_Data - #754

Open
dharmesh-12s wants to merge 5 commits into
gpsaggese:masterfrom
dharmesh-12s:UmdTask751_MSML610_Fall2026_Polars_Pandas_vs_Polars_Benchmark_on_Crypto_Trade_Data
Open

dharmesh-12s wants to merge 5 commits into
gpsaggese:masterfrom
dharmesh-12s:UmdTask751_MSML610_Fall2026_Polars_Pandas_vs_Polars_Benchmark_on_Crypto_Trade_Data

Conversation

@dharmesh-12s

@dharmesh-12s dharmesh-12s commented Oct 25, 2026 •

Copy link
Copy Markdown

What

Why

How It Works

  • Part 1, ingest: download, build 1/3/7/28-day datasets in CSV and Parquet, compare loads
  • Part 2, the wall: pandas builds 1-minute bars for the month under a 1 GB memory budget
  • Part 3, the ladder: 8 workloads (parse, sort, filter, hourly volume, VWAP, 1-minute
    bars, rolling volatility, as-of join) plus SQL, timed in pandas, Polars eager, and lazy
  • Part 4, the return: the same task with Polars lazy and streaming, then sink_parquet()
  • See README.md for the quick start

Decisions

  • ETHUSDT October 2026, as in the spec; data goes in data/, which is gitignored
  • Memory budget: each task runs in a child process whose memory is sampled with psutil
    and stopped above the budget, so the notebook kernel survives
  • Memory is measured as anonymous RSS, since Polars memory-maps the CSV
  • No DuckDB, to keep the tutorial within 60 minutes

Evidence

  • Results (12-thread laptop, Docker):
    • CSV loads: Polars 6.7x to 11.8x faster; Parquet is about 8x smaller than CSV
    • 7 days: Polars 3x to 6x faster on grouping and joins (hourly volume 5.9x, VWAP 5.2x)
    • 28 days: pandas, Polars eager, and Polars lazy go over 1 GB; Polars streaming
      finishes in 0.5 s at about 250 MB (pandas without a budget: 1,770 MB, 11.6 s)
    • 1-minute bars match the Binance klines exactly (open, high, low, close)
  • Both notebooks run end to end after a kernel restart
  • test/test_polars_utils.py: 13 unit tests (every workload pandas == Polars eager ==
    lazy, SQL, streaming, memory budget), 13 passed in Docker with
    ./docker_cmd.sh "cd /git_root && pytest <project_dir>/test/test_polars_utils.py"
  • test/test_docker_polars.py: runs both notebooks in Docker

Not in This PR

Questions for Reviewers

  • Is the 1 GB simulated memory budget a reasonable way to show the out-of-memory case?

@dharmesh-12s

Copy link
Copy Markdown
Author

Milestone 1 done: Binance ETHUSDT aggTrades ingestion (1, 7, 28 days),
CSV vs Parquet datasets, and load-time benchmark (polars.example.ipynb, Part 1).
On 28 days (16.6M rows), Polars loads CSV 12.3x faster than pandas and
Parquet 2.1x faster. Data is downloaded at run time and excluded via .gitignore.
Next: Milestone 2, polars.API.ipynb.

…oad benchmark

Pre-commit checks:
All checks passed ✅
…demo

- polars.API: expressions, contexts, time series, lazy, streaming, and SQL on toy data
- polars.example: ingest, pandas over a 1 GB memory budget, 8 workloads on 1/3/7 days, Polars streaming on 28 days
- polars_utils: workloads in pandas and Polars, memory-budget runner, plots
- Unit tests, Docker notebook tests, README, Dockerfile git safe.directory

Pre-commit checks:
All checks passed ✅
@dharmesh-12s
dharmesh-12s marked this pull request as ready for review December 4, 2026 18:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MSML610_Fall2026_Polars_Pandas_vs_Polars_Benchmark_on_Crypto_Trade_Data

1 participant