polars-1-use-lazy-evaluation-by-default
Sub-skill of polars: 1. Use Lazy Evaluation by Default (+4).
Best use case
polars-1-use-lazy-evaluation-by-default is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Sub-skill of polars: 1. Use Lazy Evaluation by Default (+4).
Teams using polars-1-use-lazy-evaluation-by-default should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/1-use-lazy-evaluation-by-default/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How polars-1-use-lazy-evaluation-by-default Compares
| Feature / Agent | polars-1-use-lazy-evaluation-by-default | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Sub-skill of polars: 1. Use Lazy Evaluation by Default (+4).
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 1. Use Lazy Evaluation by Default (+4)
## 1. Use Lazy Evaluation by Default
```python
# GOOD: Lazy evaluation allows optimization
lf = pl.scan_parquet("data.parquet")
result = (
lf
.filter(pl.col("x") > 0)
.select(["x", "y"])
.collect()
)
# AVOID: Eager evaluation for large files
df = pl.read_parquet("data.parquet") # Loads everything
df = df.filter(pl.col("x") > 0)
df = df.select(["x", "y"])
```
## 2. Chain Operations
```python
# GOOD: Single chain, optimized execution
result = (
df
.filter(pl.col("status") == "active")
.with_columns([
(pl.col("a") + pl.col("b")).alias("sum"),
pl.col("date").dt.year().alias("year")
])
.group_by("year")
.agg(pl.col("sum").mean())
)
# AVOID: Multiple separate operations
df = df.filter(pl.col("status") == "active")
df = df.with_columns((pl.col("a") + pl.col("b")).alias("sum"))
df = df.with_columns(pl.col("date").dt.year().alias("year"))
result = df.group_by("year").agg(pl.col("sum").mean())
```
## 3. Use Appropriate Data Types
```python
# Optimize memory with correct types
df = df.with_columns([
pl.col("small_int").cast(pl.Int16),
pl.col("category").cast(pl.Categorical),
pl.col("flag").cast(pl.Boolean),
pl.col("precise_float").cast(pl.Float32) # If precision allows
])
# Check memory usage
print(df.estimated_size("mb"))
```
## 4. Filter Early
```python
# GOOD: Filter before expensive operations
result = (
pl.scan_parquet("data.parquet")
.filter(pl.col("date") >= "2025-01-01") # Filter first
.group_by("category")
.agg(pl.col("value").sum())
.collect()
)
# AVOID: Filter after loading everything
result = (
pl.scan_parquet("data.parquet")
.group_by("category")
.agg(pl.col("value").sum())
.filter(...) # Too late, already processed all data
.collect()
)
```
## 5. Use Expressions Over Apply
```python
# GOOD: Vectorized expression
df.with_columns([
pl.when(pl.col("x") > 0).then(pl.col("x")).otherwise(0).alias("positive_x")
])
# AVOID: Python function (slow)
df.with_columns([
pl.col("x").map_elements(lambda v: v if v > 0 else 0).alias("positive_x")
])
```Related Skills
library-evaluation-integration
Create evaluation scripts and integration tests for Python scientific libraries in the digitalmodel package. Follows the established pattern from fluids, ht, meshio, sectionproperties, and pygmt evaluations.
parallel-batch-executor-1-always-set-a-default
Sub-skill of parallel-batch-executor: 1. Always Set a Default (+4).
json-config-loader-1-always-provide-defaults
Sub-skill of json-config-loader: 1. Always Provide Defaults (+4).
agent-teams-dm-default-always-prefer
Sub-skill of agent-teams: DM (default — always prefer) (+2).
oil-and-gas-economic-evaluation
Sub-skill of oil-and-gas: Economic Evaluation (+2).
polars-polars-with-plotly-visualization
Sub-skill of polars: Polars with Plotly Visualization (+1).
polars-6-joins-and-concatenation
Sub-skill of polars: 6. Joins and Concatenation.
polars-4-groupby-and-aggregations
Sub-skill of polars: 4. GroupBy and Aggregations (+1).
polars-3-expression-api
Sub-skill of polars: 3. Expression API.
polars-2-lazy-evaluation-and-query-optimization
Sub-skill of polars: 2. Lazy Evaluation and Query Optimization.
polars-1-dataframe-creation-and-io
Sub-skill of polars: 1. DataFrame Creation and I/O.
data-analysis-polars-high-performance-processing
Sub-skill of data-analysis: Polars High-Performance Processing (+5).