feat: funciones Python datascience, finance, cybersecurity y pipelines
Datascience: aggregate_by_group, deduplicate_entities/relations, detect_drift, diff_entities/relations, extract_entities/relations_llm, hotness_score, melt, merge_graphs, pivot, build_entity/relation_schema_prompt. Finance: avellaneda_stoikov_quotes, generate_gbm_prices, generate_taker_order, hawkes_intensity + módulo finance.py. Cybersecurity: envelope_encrypt/decrypt + módulo cybersecurity.py. Pipelines: extraction_pipeline, monte_carlo_market, run_market_sim. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
---
|
||||
name: melt
|
||||
kind: function
|
||||
lang: py
|
||||
domain: datascience
|
||||
version: "1.0.0"
|
||||
purity: pure
|
||||
signature: "def melt(rows: list[dict], id_vars: list[str], value_vars: list[str] | None = None, var_name: str = 'variable', value_name: str = 'value') -> list[dict]"
|
||||
description: "Inversa de pivot. Convierte columnas en filas (formato largo). Cada combinacion de id_vars + value_var genera una fila. Si value_vars es None, derrite todas las columnas no-id."
|
||||
tags: [datascience, tabular, melt, unpivot, transform, python]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: ""
|
||||
imports: []
|
||||
tested: true
|
||||
tests:
|
||||
- "Melt basico"
|
||||
- "Multiples id_vars"
|
||||
- "value_vars None derrite todas las columnas no-id"
|
||||
- "Fila con campo faltante en value_vars"
|
||||
test_file_path: "python/functions/datascience/melt_test.py"
|
||||
file_path: "python/functions/datascience/melt.py"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```python
|
||||
rows = [{"region": "US", "q1": 10, "q2": 20}]
|
||||
melt(rows, id_vars=["region"], value_vars=["q1", "q2"])
|
||||
# [{"region": "US", "variable": "q1", "value": 10},
|
||||
# {"region": "US", "variable": "q2", "value": 20}]
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
Funcion pura sin dependencias externas.
|
||||
Si un campo de value_vars no existe en la fila, su valor sera None.
|
||||
El parametro value_vars=None es util cuando se desconoce el schema exacto.
|
||||
Reference in New Issue
Block a user