@pikaa-ai/pikaa 0.3.22 → 0.3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/brand/orbit-logo-option4-whale.jpg +0 -0
- package/assets/brand/orbit-logo.jpg +0 -0
- package/assets/brand/orbit-logo.png +0 -0
- package/assets/brand/orbit-logo.svg +3 -0
- package/dist/cli.js +448 -181
- package/dist/index.js +22 -2
- package/package.json +1 -2
- package/skills/adaptyv/SKILL.md +0 -240
- package/skills/aeon/SKILL.md +0 -402
- package/skills/analytical-method-validation/SKILL.md +0 -299
- package/skills/anndata/SKILL.md +0 -431
- package/skills/arbor/SKILL.md +0 -152
- package/skills/arboreto/SKILL.md +0 -267
- package/skills/astropy/SKILL.md +0 -353
- package/skills/autoskill/SKILL.md +0 -233
- package/skills/benchling-integration/SKILL.md +0 -229
- package/skills/bgpt-paper-search/SKILL.md +0 -75
- package/skills/bids/SKILL.md +0 -237
- package/skills/biopython/SKILL.md +0 -472
- package/skills/bioservices/SKILL.md +0 -399
- package/skills/bulk-rnaseq/SKILL.md +0 -198
- package/skills/cellxgene-census/SKILL.md +0 -283
- package/skills/cirq/SKILL.md +0 -370
- package/skills/citation-management/SKILL.md +0 -329
- package/skills/clinical-decision-support/SKILL.md +0 -238
- package/skills/clinical-decision-support/references/README.md +0 -62
- package/skills/clinical-reports/SKILL.md +0 -248
- package/skills/clinical-reports/references/README.md +0 -34
- package/skills/cobrapy/SKILL.md +0 -496
- package/skills/consciousness-council/SKILL.md +0 -151
- package/skills/dask/SKILL.md +0 -482
- package/skills/database-lookup/SKILL.md +0 -386
- package/skills/datamol/SKILL.md +0 -200
- package/skills/deepchem/SKILL.md +0 -244
- package/skills/deepspot-m/SKILL.md +0 -175
- package/skills/deeptools/SKILL.md +0 -412
- package/skills/depmap/SKILL.md +0 -301
- package/skills/dhdna-profiler/SKILL.md +0 -184
- package/skills/diffdock/SKILL.md +0 -488
- package/skills/dnanexus-integration/SKILL.md +0 -325
- package/skills/docx/SKILL.md +0 -99
- package/skills/esm/SKILL.md +0 -334
- package/skills/etetoolkit/SKILL.md +0 -327
- package/skills/exa-search/SKILL.md +0 -102
- package/skills/executing-plans/SKILL.md +0 -14
- package/skills/experimental-design/SKILL.md +0 -234
- package/skills/exploratory-data-analysis/SKILL.md +0 -280
- package/skills/flowio/SKILL.md +0 -310
- package/skills/fluidsim/SKILL.md +0 -279
- package/skills/frontend-design/SKILL.md +0 -100
- package/skills/generate-image/SKILL.md +0 -304
- package/skills/geniml/SKILL.md +0 -310
- package/skills/genomic-coordinates/SKILL.md +0 -189
- package/skills/genomic-intelligence/SKILL.md +0 -243
- package/skills/geomaster/README.md +0 -105
- package/skills/geomaster/SKILL.md +0 -366
- package/skills/geopandas/SKILL.md +0 -250
- package/skills/get-available-resources/SKILL.md +0 -260
- package/skills/gget/SKILL.md +0 -153
- package/skills/ginkgo-cloud-lab/SKILL.md +0 -106
- package/skills/glycoengineering/SKILL.md +0 -339
- package/skills/gtars/SKILL.md +0 -282
- package/skills/guardian-rails/SKILL.md +0 -54
- package/skills/histolab/SKILL.md +0 -243
- package/skills/hugging-science/SKILL.md +0 -132
- package/skills/hypogenic/SKILL.md +0 -290
- package/skills/hypothesis-generation/SKILL.md +0 -264
- package/skills/imaging-data-commons/SKILL.md +0 -496
- package/skills/infographics/SKILL.md +0 -315
- package/skills/iso-standards-readiness/SKILL.md +0 -352
- package/skills/lab-hardware-cad/SKILL.md +0 -372
- package/skills/labarchive-integration/SKILL.md +0 -216
- package/skills/lamindb/SKILL.md +0 -408
- package/skills/latchbio-integration/SKILL.md +0 -227
- package/skills/latex-posters/SKILL.md +0 -369
- package/skills/latex-posters/references/README.md +0 -439
- package/skills/liteparse/SKILL.md +0 -295
- package/skills/literature-review/SKILL.md +0 -263
- package/skills/markdown-mermaid-writing/SKILL.md +0 -322
- package/skills/market-research-reports/SKILL.md +0 -337
- package/skills/markitdown/SKILL.md +0 -264
- package/skills/matchms/SKILL.md +0 -276
- package/skills/matlab/SKILL.md +0 -274
- package/skills/matplotlib/SKILL.md +0 -378
- package/skills/medchem/SKILL.md +0 -321
- package/skills/modal/SKILL.md +0 -468
- package/skills/molecular-dynamics/SKILL.md +0 -458
- package/skills/molfeat/SKILL.md +0 -348
- package/skills/ncats-arax/SKILL.md +0 -178
- package/skills/networkx/SKILL.md +0 -440
- package/skills/neurokit2/SKILL.md +0 -323
- package/skills/neuropixels-analysis/SKILL.md +0 -412
- package/skills/nextflow/SKILL.md +0 -195
- package/skills/omero-integration/SKILL.md +0 -222
- package/skills/onekgpd/SKILL.md +0 -371
- package/skills/ontology-term-resolution/SKILL.md +0 -147
- package/skills/open-notebook/SKILL.md +0 -297
- package/skills/openpiv/SKILL.md +0 -469
- package/skills/opentrons-integration/SKILL.md +0 -322
- package/skills/optimize-for-gpu/SKILL.md +0 -176
- package/skills/owasp-top10/SKILL.md +0 -48
- package/skills/pacsomatic/LICENSE +0 -21
- package/skills/pacsomatic/SKILL.md +0 -150
- package/skills/paper-lookup/SKILL.md +0 -263
- package/skills/paperclip/SKILL.md +0 -413
- package/skills/paperzilla/SKILL.md +0 -159
- package/skills/parallel-web/SKILL.md +0 -128
- package/skills/pathml/SKILL.md +0 -222
- package/skills/pathogen-variant-surveillance/SKILL.md +0 -208
- package/skills/pathway-enrichment/SKILL.md +0 -194
- package/skills/pdf/SKILL.md +0 -322
- package/skills/peer-review/SKILL.md +0 -288
- package/skills/penetration-testing/SKILL.md +0 -31
- package/skills/pennylane/SKILL.md +0 -240
- package/skills/phylogenetics/SKILL.md +0 -409
- package/skills/pi-agent/SKILL.md +0 -83
- package/skills/pkpd-modeling/SKILL.md +0 -381
- package/skills/polars/SKILL.md +0 -393
- package/skills/polars-bio/SKILL.md +0 -379
- package/skills/ponytail/SKILL.md +0 -31
- package/skills/ponytail-audit/SKILL.md +0 -18
- package/skills/pptx/SKILL.md +0 -246
- package/skills/pptx-posters/SKILL.md +0 -258
- package/skills/primekg/SKILL.md +0 -99
- package/skills/protocolsio-integration/SKILL.md +0 -236
- package/skills/pufferlib/SKILL.md +0 -328
- package/skills/pydeseq2/SKILL.md +0 -369
- package/skills/pydicom/SKILL.md +0 -381
- package/skills/pyhealth/SKILL.md +0 -124
- package/skills/pylabrobot/SKILL.md +0 -216
- package/skills/pymatgen/SKILL.md +0 -404
- package/skills/pymc/SKILL.md +0 -310
- package/skills/pymoo/SKILL.md +0 -276
- package/skills/pyopenms/SKILL.md +0 -179
- package/skills/pysam/SKILL.md +0 -330
- package/skills/pytdc/SKILL.md +0 -297
- package/skills/pytorch-lightning/SKILL.md +0 -191
- package/skills/pyzotero/SKILL.md +0 -137
- package/skills/qiskit/SKILL.md +0 -259
- package/skills/qutip/SKILL.md +0 -317
- package/skills/rdkit/SKILL.md +0 -94
- package/skills/relsa-severity-assessment/SKILL.md +0 -354
- package/skills/research-grants/SKILL.md +0 -296
- package/skills/research-grants/references/README.md +0 -287
- package/skills/research-lookup/README.md +0 -106
- package/skills/research-lookup/SKILL.md +0 -338
- package/skills/rowan/SKILL.md +0 -398
- package/skills/scanpy/SKILL.md +0 -303
- package/skills/scholar-evaluation/SKILL.md +0 -296
- package/skills/scientific-brainstorming/SKILL.md +0 -282
- package/skills/scientific-critical-thinking/SKILL.md +0 -180
- package/skills/scientific-schematics/SKILL.md +0 -370
- package/skills/scientific-slides/SKILL.md +0 -379
- package/skills/scientific-visualization/SKILL.md +0 -285
- package/skills/scientific-writing/SKILL.md +0 -356
- package/skills/scikit-bio/SKILL.md +0 -470
- package/skills/scikit-learn/SKILL.md +0 -324
- package/skills/scikit-survival/SKILL.md +0 -313
- package/skills/scvelo/SKILL.md +0 -328
- package/skills/scvi-tools/SKILL.md +0 -201
- package/skills/seaborn/SKILL.md +0 -254
- package/skills/security-auditor/SKILL.md +0 -37
- package/skills/shap/SKILL.md +0 -282
- package/skills/simpy/SKILL.md +0 -283
- package/skills/stable-baselines3/SKILL.md +0 -325
- package/skills/statistical-analysis/SKILL.md +0 -446
- package/skills/statistical-power/SKILL.md +0 -200
- package/skills/statsmodels/SKILL.md +0 -238
- package/skills/sympy/SKILL.md +0 -354
- package/skills/systematic-debugging/SKILL.md +0 -35
- package/skills/tamarind/SKILL.md +0 -285
- package/skills/tdd/SKILL.md +0 -26
- package/skills/tiledbvcf/SKILL.md +0 -456
- package/skills/timesfm-forecasting/SKILL.md +0 -408
- package/skills/timesfm-forecasting/examples/global-temperature/README.md +0 -178
- package/skills/torch-geometric/SKILL.md +0 -458
- package/skills/torchdrug/SKILL.md +0 -241
- package/skills/transformers/SKILL.md +0 -195
- package/skills/treatment-plans/SKILL.md +0 -174
- package/skills/treatment-plans/references/README.md +0 -19
- package/skills/umap-learn/SKILL.md +0 -488
- package/skills/uncertainty-and-units/SKILL.md +0 -384
- package/skills/usfiscaldata/SKILL.md +0 -171
- package/skills/vaex/SKILL.md +0 -204
- package/skills/venue-templates/SKILL.md +0 -269
- package/skills/verification-before-completion/SKILL.md +0 -22
- package/skills/waypoint-bio/SKILL.md +0 -273
- package/skills/what-if-oracle/SKILL.md +0 -184
- package/skills/writing-plans/SKILL.md +0 -15
- package/skills/xlsx/SKILL.md +0 -110
- package/skills/zarr-python/SKILL.md +0 -241
package/skills/polars/SKILL.md
DELETED
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: polars
|
|
3
|
-
description: High-performance DataFrame library for Python ETL, analytics, and pandas migration. Use for expression-based data manipulation with lazy query optimization, parallel execution, streaming out-of-core processing, Arrow interoperability, and optional GPU execution.
|
|
4
|
-
license: https://github.com/pola-rs/polars/blob/main/LICENSE
|
|
5
|
-
allowed-tools: Read
|
|
6
|
-
compatibility: Requires Python 3.10+ for polars 1.41.x. Install with uv pip install; optional extras enable Excel, database, cloud, pandas/NumPy, and GPU integrations.
|
|
7
|
-
metadata:
|
|
8
|
-
version: "1.1"
|
|
9
|
-
skill-author: K-Dense Inc.
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# Polars
|
|
13
|
-
|
|
14
|
-
## Overview
|
|
15
|
-
|
|
16
|
-
Polars is a lightning-fast DataFrame library for Python and Rust built on Apache Arrow. Work with Polars' expression-based API, lazy evaluation framework, and high-performance data manipulation capabilities for efficient data processing, pandas migration, and data pipeline optimization.
|
|
17
|
-
|
|
18
|
-
## Quick Start
|
|
19
|
-
|
|
20
|
-
### Installation and Basic Usage
|
|
21
|
-
|
|
22
|
-
Install the current stable Polars release verified during this refresh:
|
|
23
|
-
```bash
|
|
24
|
-
uv pip install "polars==1.41.2"
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Install optional integrations only when needed:
|
|
28
|
-
```bash
|
|
29
|
-
uv pip install "polars[excel,database,fsspec,pandas,numpy]==1.41.2"
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Basic DataFrame creation and operations:
|
|
33
|
-
```python
|
|
34
|
-
import polars as pl
|
|
35
|
-
|
|
36
|
-
# Create DataFrame
|
|
37
|
-
df = pl.DataFrame({
|
|
38
|
-
"name": ["Alice", "Bob", "Charlie"],
|
|
39
|
-
"age": [25, 30, 35],
|
|
40
|
-
"city": ["NY", "LA", "SF"]
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
# Select columns
|
|
44
|
-
df.select("name", "age")
|
|
45
|
-
|
|
46
|
-
# Filter rows
|
|
47
|
-
df.filter(pl.col("age") > 25)
|
|
48
|
-
|
|
49
|
-
# Add computed columns
|
|
50
|
-
df.with_columns(
|
|
51
|
-
age_plus_10=pl.col("age") + 10
|
|
52
|
-
)
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Core Concepts
|
|
56
|
-
|
|
57
|
-
### Expressions
|
|
58
|
-
|
|
59
|
-
Expressions are the fundamental building blocks of Polars operations. They describe transformations on data and can be composed, reused, and optimized.
|
|
60
|
-
|
|
61
|
-
**Key principles:**
|
|
62
|
-
- Use `pl.col("column_name")` to reference columns
|
|
63
|
-
- Chain methods to build complex transformations
|
|
64
|
-
- Expressions are lazy and only execute within contexts (select, with_columns, filter, group_by)
|
|
65
|
-
|
|
66
|
-
**Example:**
|
|
67
|
-
```python
|
|
68
|
-
# Expression-based computation
|
|
69
|
-
df.select(
|
|
70
|
-
pl.col("name"),
|
|
71
|
-
(pl.col("age") * 12).alias("age_in_months")
|
|
72
|
-
)
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Lazy vs Eager Evaluation
|
|
76
|
-
|
|
77
|
-
**Eager (DataFrame):** Operations execute immediately
|
|
78
|
-
```python
|
|
79
|
-
df = pl.read_csv("file.csv") # Reads immediately
|
|
80
|
-
result = df.filter(pl.col("age") > 25) # Executes immediately
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
**Lazy (LazyFrame):** Operations build a query plan, optimized before execution
|
|
84
|
-
```python
|
|
85
|
-
lf = pl.scan_csv("file.csv") # Doesn't read yet
|
|
86
|
-
result = lf.filter(pl.col("age") > 25).select("name", "age")
|
|
87
|
-
df = result.collect() # Now executes optimized query
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
**When to use lazy:**
|
|
91
|
-
- Working with large datasets
|
|
92
|
-
- Complex query pipelines
|
|
93
|
-
- When only some columns/rows are needed
|
|
94
|
-
- Performance is critical
|
|
95
|
-
|
|
96
|
-
**Benefits of lazy evaluation:**
|
|
97
|
-
- Automatic query optimization
|
|
98
|
-
- Predicate pushdown
|
|
99
|
-
- Projection pushdown
|
|
100
|
-
- Parallel execution
|
|
101
|
-
|
|
102
|
-
For detailed concepts, load `references/core_concepts.md`.
|
|
103
|
-
|
|
104
|
-
## Common Operations
|
|
105
|
-
|
|
106
|
-
### Select
|
|
107
|
-
Select and manipulate columns:
|
|
108
|
-
```python
|
|
109
|
-
# Select specific columns
|
|
110
|
-
df.select("name", "age")
|
|
111
|
-
|
|
112
|
-
# Select with expressions
|
|
113
|
-
df.select(
|
|
114
|
-
pl.col("name"),
|
|
115
|
-
(pl.col("age") * 2).alias("double_age")
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
# Select all columns matching a pattern
|
|
119
|
-
df.select(pl.col("^.*_id$"))
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Filter
|
|
123
|
-
Filter rows by conditions:
|
|
124
|
-
```python
|
|
125
|
-
# Single condition
|
|
126
|
-
df.filter(pl.col("age") > 25)
|
|
127
|
-
|
|
128
|
-
# Multiple conditions (cleaner than using &)
|
|
129
|
-
df.filter(
|
|
130
|
-
pl.col("age") > 25,
|
|
131
|
-
pl.col("city") == "NY"
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
# Complex conditions
|
|
135
|
-
df.filter(
|
|
136
|
-
(pl.col("age") > 25) | (pl.col("city") == "LA")
|
|
137
|
-
)
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### With Columns
|
|
141
|
-
Add or modify columns while preserving existing ones:
|
|
142
|
-
```python
|
|
143
|
-
# Add new columns
|
|
144
|
-
df.with_columns(
|
|
145
|
-
age_plus_10=pl.col("age") + 10,
|
|
146
|
-
name_upper=pl.col("name").str.to_uppercase()
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
# Parallel computation (all columns computed in parallel)
|
|
150
|
-
df.with_columns(
|
|
151
|
-
pl.col("value") * 10,
|
|
152
|
-
pl.col("value") * 100,
|
|
153
|
-
)
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### Group By and Aggregations
|
|
157
|
-
Group data and compute aggregations:
|
|
158
|
-
```python
|
|
159
|
-
# Basic grouping
|
|
160
|
-
df.group_by("city").agg(
|
|
161
|
-
pl.col("age").mean().alias("avg_age"),
|
|
162
|
-
pl.len().alias("count")
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
# Multiple group keys
|
|
166
|
-
df.group_by("city", "department").agg(
|
|
167
|
-
pl.col("salary").sum()
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
# Conditional aggregations
|
|
171
|
-
df.group_by("city").agg(
|
|
172
|
-
(pl.col("age") > 30).sum().alias("over_30")
|
|
173
|
-
)
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
For detailed operation patterns, load `references/operations.md`.
|
|
177
|
-
|
|
178
|
-
## Aggregations and Window Functions
|
|
179
|
-
|
|
180
|
-
### Aggregation Functions
|
|
181
|
-
Common aggregations within `group_by` context:
|
|
182
|
-
- `pl.len()` - count rows
|
|
183
|
-
- `pl.col("x").sum()` - sum values
|
|
184
|
-
- `pl.col("x").mean()` - average
|
|
185
|
-
- `pl.col("x").min()` / `pl.col("x").max()` - extremes
|
|
186
|
-
- `pl.first()` / `pl.last()` - first/last values
|
|
187
|
-
|
|
188
|
-
### Window Functions with `over()`
|
|
189
|
-
Apply aggregations while preserving row count:
|
|
190
|
-
```python
|
|
191
|
-
# Add group statistics to each row
|
|
192
|
-
df.with_columns(
|
|
193
|
-
avg_age_by_city=pl.col("age").mean().over("city"),
|
|
194
|
-
rank_in_city=pl.col("salary").rank().over("city")
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
# Multiple grouping columns
|
|
198
|
-
df.with_columns(
|
|
199
|
-
group_avg=pl.col("value").mean().over("category", "region")
|
|
200
|
-
)
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
**Mapping strategies:**
|
|
204
|
-
- `group_to_rows` (default): Preserves original row order
|
|
205
|
-
- `explode`: Faster but groups rows together
|
|
206
|
-
- `join`: Creates list columns
|
|
207
|
-
|
|
208
|
-
## Data I/O
|
|
209
|
-
|
|
210
|
-
### Supported Formats
|
|
211
|
-
Polars supports reading and writing:
|
|
212
|
-
- CSV, Parquet, JSON, Excel
|
|
213
|
-
- Databases (via connectors)
|
|
214
|
-
- Cloud storage (S3, Azure, GCS)
|
|
215
|
-
- Google BigQuery
|
|
216
|
-
- Multiple/partitioned files
|
|
217
|
-
|
|
218
|
-
### Common I/O Operations
|
|
219
|
-
|
|
220
|
-
**CSV:**
|
|
221
|
-
```python
|
|
222
|
-
# Eager
|
|
223
|
-
df = pl.read_csv("file.csv")
|
|
224
|
-
df.write_csv("output.csv")
|
|
225
|
-
|
|
226
|
-
# Lazy (preferred for large files)
|
|
227
|
-
lf = pl.scan_csv("file.csv")
|
|
228
|
-
result = lf.filter(...).select(...).collect()
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
**Parquet (recommended for performance):**
|
|
232
|
-
```python
|
|
233
|
-
df = pl.read_parquet("file.parquet")
|
|
234
|
-
df.write_parquet("output.parquet")
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
**JSON:**
|
|
238
|
-
```python
|
|
239
|
-
df = pl.read_json("file.json")
|
|
240
|
-
df.write_json("output.json")
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
For comprehensive I/O documentation, load `references/io_guide.md`.
|
|
244
|
-
|
|
245
|
-
## Transformations
|
|
246
|
-
|
|
247
|
-
### Joins
|
|
248
|
-
Combine DataFrames:
|
|
249
|
-
```python
|
|
250
|
-
# Inner join
|
|
251
|
-
df1.join(df2, on="id", how="inner")
|
|
252
|
-
|
|
253
|
-
# Left join
|
|
254
|
-
df1.join(df2, on="id", how="left")
|
|
255
|
-
|
|
256
|
-
# Join on different column names
|
|
257
|
-
df1.join(df2, left_on="user_id", right_on="id")
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
### Concatenation
|
|
261
|
-
Stack DataFrames:
|
|
262
|
-
```python
|
|
263
|
-
# Vertical (stack rows)
|
|
264
|
-
pl.concat([df1, df2], how="vertical")
|
|
265
|
-
|
|
266
|
-
# Horizontal (add columns)
|
|
267
|
-
pl.concat([df1, df2], how="horizontal")
|
|
268
|
-
|
|
269
|
-
# Diagonal (union with different schemas)
|
|
270
|
-
pl.concat([df1, df2], how="diagonal")
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
### Pivot and Unpivot
|
|
274
|
-
Reshape data:
|
|
275
|
-
```python
|
|
276
|
-
# Pivot (wide format)
|
|
277
|
-
df.pivot(on="product", values="sales", index="date")
|
|
278
|
-
|
|
279
|
-
# Unpivot (long format)
|
|
280
|
-
df.unpivot(index="id", on=["col1", "col2"])
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
For detailed transformation examples, load `references/transformations.md`.
|
|
284
|
-
|
|
285
|
-
## Pandas Migration
|
|
286
|
-
|
|
287
|
-
Polars offers significant performance improvements over pandas with a cleaner API. Key differences:
|
|
288
|
-
|
|
289
|
-
### Conceptual Differences
|
|
290
|
-
- **No index**: Polars uses integer positions only
|
|
291
|
-
- **Strict typing**: No silent type conversions
|
|
292
|
-
- **Lazy evaluation**: Available via LazyFrame
|
|
293
|
-
- **Parallel by default**: Operations parallelized automatically
|
|
294
|
-
|
|
295
|
-
### Common Operation Mappings
|
|
296
|
-
|
|
297
|
-
| Operation | Pandas | Polars |
|
|
298
|
-
|-----------|--------|--------|
|
|
299
|
-
| Select column | `df["col"]` | `df.select("col")` |
|
|
300
|
-
| Filter | `df[df["col"] > 10]` | `df.filter(pl.col("col") > 10)` |
|
|
301
|
-
| Add column | `df.assign(x=...)` | `df.with_columns(x=...)` |
|
|
302
|
-
| Group by | `df.groupby("col").agg(...)` | `df.group_by("col").agg(...)` |
|
|
303
|
-
| Window | `df.groupby("col").transform(...)` | `df.with_columns(...).over("col")` |
|
|
304
|
-
|
|
305
|
-
### Key Syntax Patterns
|
|
306
|
-
|
|
307
|
-
**Pandas sequential (slow):**
|
|
308
|
-
```python
|
|
309
|
-
df.assign(
|
|
310
|
-
col_a=lambda df_: df_.value * 10,
|
|
311
|
-
col_b=lambda df_: df_.value * 100
|
|
312
|
-
)
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
**Polars parallel (fast):**
|
|
316
|
-
```python
|
|
317
|
-
df.with_columns(
|
|
318
|
-
col_a=pl.col("value") * 10,
|
|
319
|
-
col_b=pl.col("value") * 100,
|
|
320
|
-
)
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
For comprehensive migration guide, load `references/pandas_migration.md`.
|
|
324
|
-
|
|
325
|
-
## Best Practices
|
|
326
|
-
|
|
327
|
-
### Performance Optimization
|
|
328
|
-
|
|
329
|
-
1. **Use lazy evaluation for large datasets:**
|
|
330
|
-
```python
|
|
331
|
-
lf = pl.scan_csv("large.csv") # Don't use read_csv
|
|
332
|
-
result = lf.filter(...).select(...).collect()
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
2. **Avoid Python functions in hot paths:**
|
|
336
|
-
- Stay within expression API for parallelization
|
|
337
|
-
- Use `.map_elements()` only when necessary
|
|
338
|
-
- Prefer native Polars operations
|
|
339
|
-
|
|
340
|
-
3. **Use streaming for very large data:**
|
|
341
|
-
```python
|
|
342
|
-
lf.collect(engine="streaming")
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
4. **Select only needed columns early:**
|
|
346
|
-
```python
|
|
347
|
-
# Good: Select columns early
|
|
348
|
-
lf.select("col1", "col2").filter(...)
|
|
349
|
-
|
|
350
|
-
# Bad: Filter on all columns first
|
|
351
|
-
lf.filter(...).select("col1", "col2")
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
5. **Use appropriate data types:**
|
|
355
|
-
- Categorical for low-cardinality strings
|
|
356
|
-
- Appropriate integer sizes (i32 vs i64)
|
|
357
|
-
- Date types for temporal data
|
|
358
|
-
|
|
359
|
-
### Expression Patterns
|
|
360
|
-
|
|
361
|
-
**Conditional operations:**
|
|
362
|
-
```python
|
|
363
|
-
pl.when(condition).then(value).otherwise(other_value)
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
**Column operations across multiple columns:**
|
|
367
|
-
```python
|
|
368
|
-
df.select(pl.col("^.*_value$") * 2) # Regex pattern
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
**Null handling:**
|
|
372
|
-
```python
|
|
373
|
-
pl.col("x").fill_null(0)
|
|
374
|
-
pl.col("x").is_null()
|
|
375
|
-
pl.col("x").drop_nulls()
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
For additional best practices and patterns, load `references/best_practices.md`.
|
|
379
|
-
|
|
380
|
-
## Resources
|
|
381
|
-
|
|
382
|
-
This skill includes comprehensive reference documentation:
|
|
383
|
-
|
|
384
|
-
### references/
|
|
385
|
-
- `core_concepts.md` - Detailed explanations of expressions, lazy evaluation, and type system
|
|
386
|
-
- `operations.md` - Comprehensive guide to all common operations with examples
|
|
387
|
-
- `pandas_migration.md` - Complete migration guide from pandas to Polars
|
|
388
|
-
- `io_guide.md` - Data I/O operations for all supported formats
|
|
389
|
-
- `transformations.md` - Joins, concatenation, pivots, and reshaping operations
|
|
390
|
-
- `best_practices.md` - Performance optimization tips and common patterns
|
|
391
|
-
|
|
392
|
-
Load these references as needed when users require detailed information about specific topics.
|
|
393
|
-
|