σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
Parquet skill›Module 1 · Inside the file›Topic 1.2·~50 minIntermediate

Row groups and pages

Skill positionModule 1 of 3 · Topic 2 of 3
1.2 Row groups and pages
—Lab score— / 100Total XP—Streak—
Lecture0% read

3 min readCode examples: 3

  1. 01The idea in plain words
  2. 02Row groups: the block you can fetch alone
  3. 03Encodings: fewer bytes before compression
  4. 04What the tasks ask

A Parquet file is not one long block of numbers. It is cut into row groups, each row group into one chunk per column, each chunk into pages, and every page is encoded and then compressed. Knowing the layers explains every speed trick in the next topics, because each of them skips at one of these levels.

01

The idea in plain words

Where we are. The previous topic showed that columns are stored apart and that the footer says where. This one goes one level down: the row group is the block a reader can fetch alone, and the encoding decides how few bytes a column needs before the codec in the next topic even starts.

DefinitionRow group

A horizontal block of a Parquet file: a fixed number of rows, stored as one chunk per column. Each row group carries its own metadata, so a reader can fetch one, or skip it, without touching the others.

02

Row groups: the block you can fetch alone

The writer's row_group_size sets how many rows go in each block. Too small and the file drowns in per-group overhead; too large and a reader cannot skip finely or hold a block in memory. write_grouped picks the size, group_rows reads the result back from the footer, and read_group fetches one block without reading the others.

main.pyPython
# Cut the table into row groups of 10,000 rows and list them from the footerprint("row groups:", write_grouped(table, "g.parquet", 10000))print("rows in each:", group_rows("g.parquet"))
row groups: 4
rows in each: [10000, 10000, 10000, 3493]
main.pyPython
# Fetch only the last row group, the tail of the last stock's barslast = read_group("g.parquet", 3)print(last.num_rows, "rows;", "first date:", last.column("date")[0], "| last date:", last.column("date")[-1])
3493 rows; first date: 2012-09-28 | last date: 2026-08-21
03

Encodings: fewer bytes before compression

Inside a chunk, values are first encoded. PLAIN writes every value in full. Dictionary encoding (RLE_DICTIONARY) writes each distinct value once and then a small integer per row, with runs of the same integer folded by RLE. A column like symbol, with five distinct values over 33,000 rows, collapses to almost nothing. A column of prices, almost all distinct, can even grow, as the output below shows.

main.pyPython
# Dictionary encoding on and off: the encodings of symbol, and the bytes each setting gives symbol and closedef chunk_size(path, name):    group = pq.ParquetFile(path).metadata.row_group(0)    return sum(group.column(c).total_compressed_size for c in range(group.num_columns) if group.column(c).path_in_schema == name)for flag in (True, False):    names = encodings_of(table, "d.parquet", "symbol", flag)    print("dictionary", flag, names, "| symbol bytes:", chunk_size("d.parquet", "symbol"), "| close bytes:", chunk_size("d.parquet", "close"))
dictionary True ['PLAIN', 'RLE', 'RLE_DICTIONARY'] | symbol bytes: 161 | close bytes: 229798
dictionary False ['PLAIN', 'RLE'] | symbol bytes: 11167 | close bytes: 177572
Pick row-group sizes on purpose

Engines default to around a million rows or about 128 MB per group, because a block should be big enough to compress well and small enough to fit in memory. For files you query by date range, write rows in date order first: then each row group covers a narrow range and the next topics can skip most of them.

04

What the tasks ask

  1. 1
    `write_grouped` and `group_rows`Pass row_group_size to pq.write_table, then read metadata.num_row_groups and each row_group(g).num_rows.
  2. 2
    `read_group`pq.ParquetFile(path).read_row_group(index) fetches that block alone.
  3. 3
    `encodings_of`Write with use_dictionary=..., then find the column chunk by path_in_schema and return sorted(chunk.encodings).

Key takeaways

  • Row groups are the unit of skipping A reader fetches or skips whole blocks using their metadata.
  • Encoding comes before compression Dictionary encoding makes repetitive columns tiny; prices can even grow.
  • Order the rows first Sorted data gives each block a narrow range. Next: compression codecs.
Quick check
Why does dictionary encoding shrink the symbol column far more than the close column?
Pick an answer.

Lab · what's graded

4 tasks · 100 pts
  • Choose the row-group size: write_grouped25 pts
  • List the row groups: group_rows25 pts
  • Read one row group alone: read_group25 pts
  • See how a column is encoded: encodings_of25 pts
Explorer · lab-2-1
▾ lab-2-1
▾ data
…
bash · in-browser
learner@quantcraft:~/lab-2-1$
Python not loaded yetPythonLn 1, Col 1Spaces: 4UTF-8

Reset this topic?

Everything in lab-2-1 goes back to the starter files and the terminal is cleared. Your current solution will be lost — this can't be undone.

Will be reset
  • main.py → starter code
  • Terminal history and test output
  • Unsubmitted changes
Will be kept
  • Best lab score
  • Your XP and streak
  • Lecture progress and notes