用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/vamseeachanta/workspace-hub --skill polars-2-lazy-evaluation-and-query-optimization命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Write outbound email and external messages in Vamsee Achanta's voice — a subtle offer to help, never bold or rash claims. Load before drafting ANY email, LinkedIn/Collide reply, proposal note, or outreach sent under his name.
Save/publish analysis or computation results from ANY ecosystem repo to Hugging Face as a queryable, viewer-renderable dataset. Use when the user wants to "save results to hugging face", "publish dataset to HF", "hugging face data saving", "save analysis results", "hf dataset", "make results queryable", or "render via datasets-server API". Reshapes nested results into flat parquet tables, writes a dataset card with a viewer `configs:` block and provenance, applies license/public-vs-private routing, enforces a domain data-quality gate (faithful-to-source != correct), publishes to `aceengineer/<repo>-<projection>`, and verifies via the datasets-server API.
Clone, create, fork, configure, and manage GitHub repositories. Manage remotes, secrets, releases, and workflows. Works with gh CLI or falls back to git + GitHub REST API via curl.
正在显示 SKILL.md
基于 SOC 职业分类
| name | polars-2-lazy-evaluation-and-query-optimization |
| description | Sub-skill of polars: 2. Lazy Evaluation and Query Optimization. |
| version | 1.0.0 |
| category | data-analysis |
| type | reference |
| scripts_exempt | true |
LazyFrame Basics:
import polars as pl
# Create lazy frame (no computation yet)
lf = pl.scan_csv("large_data.csv")
# Or convert from eager DataFrame
df = pl.DataFrame({"x": [1, 2, 3]})
lf = df.lazy()
# Chain operations (still no computation)
result_lf = (
lf
.filter(pl.col("date") >= "2025-01-01")
.with_columns([
(pl.col("revenue") - pl.col("cost")).alias("profit"),
pl.col("category").cast(pl.Categorical)
])
.group_by("category")
.agg([
pl.col("profit").sum().alias("total_profit"),
pl.col("profit").mean().alias("avg_profit"),
pl.count().alias("count")
])
.sort("total_profit", descending=True)
)
# View the query plan
print(result_lf.explain())
# Execute and collect results
result_df = result_lf.collect()
# Execute with streaming (for very large data)
result_df = result_lf.collect(streaming=True)
# Fetch only first N rows
sample = result_lf.fetch(1000)
Query Optimization Benefits:
# Polars optimizes this automatically:
lf = (
pl.scan_parquet("data/*.parquet")
.filter(pl.col("country") == "USA") # Predicate pushdown
.select(["id", "name", "revenue"]) # Projection pushdown
.filter(pl.col("revenue") > 1000) # Combined with first filter
)
# View optimized plan
print("Naive plan:")
print(lf.explain(optimized=False))
print("\nOptimized plan:")
print(lf.explain(optimized=True))
# The optimizer will:
# 1. Push filters to data source (read less data)
# 2. Select only needed columns (reduce memory)
# 3. Combine/reorder operations for efficiency
# 4. Eliminate redundant operations
Streaming Large Files:
# Process files larger than memory
def process_large_file(input_path: str, output_path: str):
"""Process file that doesn't fit in memory."""
result = (
pl.scan_csv(input_path)
.filter(pl.col("status") == "active")
.group_by("region")
.agg([
pl.col("sales").sum(),
pl.col("customers").n_unique()
])
.collect(streaming=True) # Stream processing
)
result.write_parquet(output_path)
return result
# Sink directly to file (even more memory efficient)
(
pl.scan_csv("huge_file.csv")
.filter(pl.col("value") > 0)
.sink_parquet("filtered_output.parquet")
)