---
name: group_by
kind: function
lang: go
domain: datascience
version: "1.0.0"
purity: pure
signature: "func GroupBy[T any, K comparable](xs []T, keyFn func(T) K) map[K][]T"
description: "Agrupa los elementos de un slice según una función clave, devolviendo un mapa de clave a slice de elementos."
tags: [datascience, group, aggregate, generic, pendiente-usar, transformer]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: ""
imports: []
params:
  - name: xs
    desc: "slice de elementos a agrupar (tipo genérico T)"
  - name: keyFn
    desc: "función que extrae la clave de agrupación de cada elemento (ej: func(u User) string { return u.Department })"
output: "mapa de clave a slice de elementos agrupados (ej: {'Sales': [user1, user2], 'Engineering': [user3]})"
tested: false
tests: []
test_file_path: ""
file_path: "functions/datascience/group_by.go"
---
