Ë
    èlÖiä  ã                   ó0   — d dl mZ d dlmZ d dlmZ dd„Zy)é    )ÚOrderedDict)ÚText)ÚTableSetNc                 óp  — t        |d«      }|r|xs d}|xs
 t        «       }n/| j                  |   }|xs |j                  }|xs |j                  }t        «       }| j                  D ]J  }|r	 ||«      }n|j                     }|j                  |«      }||vrg ||<   ||   j                  |«       ŒL |st        | j                  g «      gg ||¬«      S t        «       }	|j                  «       D ]  \  }
}| j                  |«      |	|
<   Œ t        |	j                  «       |	j                  «       ||¬«      S )aŠ  
    Create a :class:`.TableSet` with a table for each unique key.

    Note that group names will always be coerced to a string, regardless of the
    format of the input column.

    :param key:
        Either the name of a column from the this table to group by, or a
        :class:`function` that takes a row and returns a value to group by.
    :param key_name:
        A name that describes the grouped properties. Defaults to the
        column name that was grouped on or "group" if grouping with a key
        function. See :class:`.TableSet` for more.
    :param key_type:
        An instance of any subclass of :class:`.DataType`. If not provided
        it will default to a :class`.Text`.
    :returns:
        A :class:`.TableSet` mapping where the keys are unique values from
        the :code:`key` and the values are new :class:`.Table` instances
        containing the grouped rows.
    Ú__call__Úgroup)Úkey_nameÚkey_type)Úhasattrr   Ú_columnsÚnameÚ	data_typer   Ú_rowsÚcastÚappendr   Ú_forkÚitemsÚvaluesÚkeys)ÚselfÚkeyr	   r
   Úkey_is_row_functionÚcolumnÚgroupsÚrowÚ
group_nameÚoutputr   Úrowss               úY/var/www/html/strategist-ai/venv_dbt/lib/python3.12/site-packages/agate/table/group_by.pyÚgroup_byr       s0  € ô, " # zÓ2ÐáØÒ&˜wˆØÒ%œt›v‰à—‘˜sÑ#ˆàÒ*˜vŸ{™{ˆØÒ/˜v×/Ñ/ˆä‹]€Fà�z‰zò 'ˆÙÙ˜S›‰Jà˜VŸ[™[Ñ)ˆJà—]‘] :Ó.ˆ
à˜VÑ#Ø!#ˆF�:ÑàˆzÑ×!Ñ! #Õ&ð'ñ Ü˜Ÿ™ B›Ð(¨"°xÈ(ÔSÐSä‹]€Fà—|‘|“~ò )‰ˆˆtØŸ
™
 4Ó(ˆˆuŠð)ô �F—M‘M“O V§[¡[£]¸XÐPXÔYÐYó    )NN)Úcollectionsr   Úagate.data_typesr   Úagate.tablesetr   r    © r!   r   ú<module>r&      s   ðÝ #å !Ý #ô8Zr!   