Skip to content

Polars/phase 0 anti patterns#1045

Draft
EngCaioFonseca wants to merge 3 commits intodevfrom
polars/phase-0-anti-patterns
Draft

Polars/phase 0 anti patterns#1045
EngCaioFonseca wants to merge 3 commits intodevfrom
polars/phase-0-anti-patterns

Conversation

@EngCaioFonseca
Copy link
Copy Markdown
Contributor

PR part of a series for the 8Knot migration to Polars processing and Pandas for only visualizations.

Generative AI disclosure

  • This contribution was assisted or created by Generative AI tools.
    • What tools were used?
    • How were these tools used?
    • Did you review these outputs before submitting this PR?

Phase 0 Progress:
- Remove .iterrows() in contrib_importance_over_time.py (10-100x speedup)
  - Replaced with vectorized cumsum + searchsorted
- Vectorize 12 .apply() calls:
  - repo_general_info.py: .apply(lambda x: x.days) -> .dt.days
  - project_velocity.py: .apply(math.log) -> np.log / np.where
  - heatmap files: set() conversion via list comprehension
  - augur_manager.py: .apply(str.lower) -> .str.lower()
  - pr_over_time.py: row-by-row get_open -> vectorized get_open_vectorized
  - issues_over_time.py: row-by-row get_open -> vectorized get_open_vectorized
- Remove 36 active inplace=True patterns
  - Use functional chaining (df = df.drop/rename/etc.)
  - Use reset_index(drop=True) instead of reset_index() + drop('index')

Migration Plan:
- Add POLARS_MIGRATION_PLAN.md with 'Polars Core, Pandas Edge' architecture
- Polars for data processing, Pandas at visualization boundary (Plotly/Dash)
- Remaining .apply() calls (21) are complex stateful ops -> Phase 3+ candidates

Performance improvements:
- .iterrows() removal: 10-100x faster for lottery factor calculation
- .apply() vectorization: 5-50x faster for date-based counting
- Cleaner code: functional patterns easier to reason about
@EngCaioFonseca EngCaioFonseca self-assigned this Dec 19, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 19, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch polars/phase-0-anti-patterns

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@EngCaioFonseca EngCaioFonseca moved this from Backlog to In Progress in Aspen Project Board Dec 19, 2025
@EngCaioFonseca EngCaioFonseca moved this from In Progress to "On Deck" in Aspen Project Board Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: "On Deck"

Development

Successfully merging this pull request may close these issues.

1 participant