Skip to content

feat: convert tidy data chapter from pandas to Polars - #9

Merged
brentomagic merged 3 commits into
mainfrom
tidydata-conversion-to-polars
Jul 27, 2026
Merged

feat: convert tidy data chapter from pandas to Polars#9
brentomagic merged 3 commits into
mainfrom
tidydata-conversion-to-polars

Conversation

@meshackamadi

Copy link
Copy Markdown
Collaborator

Summary

This PR converts the Tidy Data chapter from pandas to Polars and updates the accompanying explanations to align with the Polars API and data model.

Changes

  • Replaced pandas examples with their Polars equivalents.
  • Updated reshaping examples to use unpivot() instead of melt().
  • Updated pivot() examples to use the Polars API (on= instead of columns=).
  • Replaced pd.read_parquet() with pl.read_parquet().
  • Replaced DataFrame creation examples with pl.DataFrame.
  • Updated text throughout the chapter to reference Polars instead of pandas.
  • Removed pandas index-based operations where Polars has no equivalent.
  • Revised explanations to reflect Polars' expression-based workflow.

Documentation updates

  • Updated prerequisites to use Polars.
  • Renamed the reshaping tools section to reference Polars.
  • Improved explanations of tidy data using Polars terminology.

Notes

Testing

  • All notebook cells execute successfully.
  • Quarto renders successfully.
  • pre-commit run --all-files passes.

@meshackamadi
meshackamadi requested a review from ugohuche July 16, 2026 20:37
@meshackamadi
meshackamadi requested a review from brentomagic July 24, 2026 14:51
@meshackamadi

Copy link
Copy Markdown
Collaborator Author

Changes

Code Migration

  • pd.date_range()pl.date_range() with eager collection
  • .pivot(columns=...).pivot(on=...) (modern polars API)
  • Removed all pandas imports and dependencies
  • Updated exercise hints to idiomatic polars syntax

Terminology & Prose

  • "melting" → "unpivoting"
  • "NA"/"NaN" → "null" where appropriate
  • Reframed stack/unstack section to focus on polars reshaping (no MultiIndex)
  • Updated exercise prompts to reflect polars behavior

Files Modified

  • data-tidy.ipynb

@brentomagic brentomagic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@brentomagic
brentomagic dismissed their stale review July 27, 2026 07:49

Approving after reconsidering — leftover melt wording is fine for now.

@brentomagic brentomagic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — approving the tidy-data Polars migration.

@brentomagic
brentomagic merged commit 0ff916f into main Jul 27, 2026
2 checks passed
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.

2 participants