cfdf515228
- .claude/CLAUDE.md - .claude/commands/subagentes.md - .claude/rules/INDEX.md - .mcp.json - bash/functions/cybersecurity/analyze_dns.md - bash/functions/cybersecurity/audit_http_headers.md - bash/functions/cybersecurity/audit_ssh_config.md - bash/functions/cybersecurity/check_firewall.md - bash/functions/cybersecurity/detect_suspicious_users.md - bash/functions/cybersecurity/encrypt_file.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.0 KiB
2.0 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | |||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| aggregate_by_group | function | py | datascience | 1.0.0 | pure | def aggregate_by_group(rows: list[dict], group_by: list[str], aggs: dict[str, str]) -> list[dict] | GROUP BY + agregaciones sobre datos tabulares. aggs es un dict de columna a funcion (sum, mean, count, min, max, first, last, collect). collect acumula valores en lista. None se ignora en agregaciones numericas. |
|
false |
|
|
lista de dicts donde cada dict es un grupo con sus resultados de agregacion | true |
|
python/functions/datascience/aggregate_by_group_test.py | python/functions/datascience/aggregate_by_group.py |
Ejemplo
rows = [
{"dept": "eng", "salary": 100},
{"dept": "eng", "salary": 120},
{"dept": "sales", "salary": 80},
]
aggregate_by_group(rows, group_by=["dept"], aggs={"salary": "mean"})
# [{"dept": "eng", "salary": 110.0}, {"dept": "sales", "salary": 80.0}]
Notas
Funcion pura sin dependencias externas (solo collections.defaultdict de stdlib). Preserva el orden de primera aparicion de cada grupo. La funcion 'collect' no filtra None — acumula todos los valores incluyendo None.