ó
    Ñ]j<V  ã                  óh  • S SK Jr  S SKrS SKJr  S SKrS SKJr  S SK	J
r
Jr  S SKJr  S SKJr  S SKJs  Jr  S SKJr  S S	KJr  S S
KJr  \(       a  S SKJr  S SKJr  S SKJr  SS jr \" S5            S       SS jj5       r!\" S5      SSS jj5       r"\" S5       S       SS jj5       r#g)é    )ÚannotationsN)ÚTYPE_CHECKING)Ú
set_module)Úis_iteratorÚis_list_like)Úconcat_compat)Únotna)Ú
MultiIndex)Úconcat)Ú
to_numeric)ÚHashable)ÚAnyArrayLike)Ú	DataFramec                ó¸   • U bV  [        U 5      (       d  U /$ [        U[        5      (       a#  [        U [        5      (       d  [	        U S35      e[        U 5      $ / $ )Nz7 must be a list of tuples when columns are a MultiIndex)r   Ú
isinstancer
   ÚlistÚ
ValueError)Úarg_varsÚvariableÚcolumnss      ÚU/home/mande/repo/quber/.venv/lib/python3.13/site-packages/pandas/core/reshape/melt.pyÚensure_list_varsr      s]   € ØÑÜ˜H×%Ñ%Ø�:ÐÜ˜¤×,Ñ,´ZÀÌ$×5OÑ5OÜØ�*ÐSÐTóð ô ˜“>Ð!àˆ	ó    Úpandasc           
     óÜ
  • X@R                   ;   a  [        SU S35      e[        USU R                   5      nUSLn[        USU R                   5      n[        U R                   R	                  U5      5      [        U5      :”  a  [        S5      eU(       d  U(       aÎ  Ub  U R                   R                  U5      nOU R                   nX-   n	UR	                  U	5      n
U
S:H  nUR                  5       (       a5  [        X›SS	9 VVs/ s H  u  pÍU(       d  M  UPM     nnn[        S
U 35      eU(       a(  U R                  SS2[        R                  " U
5      4   n OU R                  SS9n OU R                  SS9n Ub   U R                   R                  U5      U l         Ucí  [        U R                   [        5      (       a�  [        U R                   R                  5      [        [!        U R                   R                  5      5      :X  a  U R                   R                  nGO[#        [        U R                   R                  5      5       Vs/ s H  nSU 3PM
     nnOãU R                   R$                  b  U R                   R$                  OS/nO²['        U5      (       aŸ  [        U R                   [        5      (       ap  [)        U5      (       a  [+        U5      n[        U5      [        U R                   5      :”  a2  [        SU< S[        U5       S[        U R                   5       S35      eO[        SU< S35      eU/nU R,                  u  nnU[        U5      -
  n0 nU H¤  nU R/                  U5      n[        UR0                  [2        R0                  5      (       dC  US:”  a  [5        U/U-  SS9UU'   MV  [7        U5      " / UR$                  UR0                  S9UU'   M€  [2        R8                  " UR:                  U5      UU'   M¦     X-   U/-   nU R,                  S   S:”  ap  [        S U R<                   5       5      (       dO  [5        [#        U R,                  S   5       Vs/ s H  oðR                  SS2U4   PM     snSS9R>                  UU'   OU R:                  RA                  S5      UU'   [C        U5       H3  u  nnU R                   RE                  U5      RG                  U5      UU'   M5     U RI                  UUS9nU(       dT  [2        R8                  " [2        RJ                  " [        U 5      5      U5      nU RL                  RO                  U5      Ul&        U$ s  snnf s  snf s  snf )a  
Unpivot a DataFrame from wide to long format, optionally leaving identifiers set.

This function is useful to reshape a DataFrame into a format where one
or more columns are identifier variables (`id_vars`), while all other
columns are considered measured variables (`value_vars`), and are "unpivoted" to
the row axis, leaving just two non-identifier columns, 'variable' and
'value'.

Parameters
----------
frame : DataFrame
    The DataFrame to unpivot.
id_vars : scalar, tuple, list, or ndarray, optional
    Column(s) to use as identifier variables.
value_vars : scalar, tuple, list, or ndarray, optional
    Column(s) to unpivot. If not specified, uses all columns that
    are not set as `id_vars`.
var_name : scalar, tuple, list, or ndarray, optional
    Name to use for the 'variable' column. If None it uses
    ``frame.columns.name`` or 'variable'. Must be a scalar if columns are a
    MultiIndex.
value_name : scalar, default 'value'
    Name to use for the 'value' column, can't be an existing column label.
col_level : scalar, optional
    If columns are a MultiIndex then use this level to melt.
ignore_index : bool, default True
    If True, original index is ignored. If False, the original index is retained.
    Index labels will be repeated as necessary.

Returns
-------
DataFrame
    Unpivoted DataFrame.

See Also
--------
DataFrame.melt : Identical method.
pivot_table : Create a spreadsheet-style pivot table as a DataFrame.
DataFrame.pivot : Return reshaped DataFrame organized
    by given index / column values.
DataFrame.explode : Explode a DataFrame from list-like
        columns to long format.

Notes
-----
Reference :ref:`the user guide <reshaping.melt>` for more examples.

Examples
--------
>>> df = pd.DataFrame(
...     {
...         "A": {0: "a", 1: "b", 2: "c"},
...         "B": {0: 1, 1: 3, 2: 5},
...         "C": {0: 2, 1: 4, 2: 6},
...     }
... )
>>> df
A  B  C
0  a  1  2
1  b  3  4
2  c  5  6

>>> pd.melt(df, id_vars=["A"], value_vars=["B"])
A variable  value
0  a        B      1
1  b        B      3
2  c        B      5

>>> pd.melt(df, id_vars=["A"], value_vars=["B", "C"])
A variable  value
0  a        B      1
1  b        B      3
2  c        B      5
3  a        C      2
4  b        C      4
5  c        C      6

The names of 'variable' and 'value' columns can be customized:

>>> pd.melt(
...     df,
...     id_vars=["A"],
...     value_vars=["B"],
...     var_name="myVarname",
...     value_name="myValname",
... )
A myVarname  myValname
0  a         B          1
1  b         B          3
2  c         B          5

Original index values can be kept around:

>>> pd.melt(df, id_vars=["A"], value_vars=["B", "C"], ignore_index=False)
A variable  value
0  a        B      1
1  b        B      3
2  c        B      5
0  a        C      2
1  b        C      4
2  c        C      6

If you have multi-index columns:

>>> df.columns = [list("ABC"), list("DEF")]
>>> df
A  B  C
D  E  F
0  a  1  2
1  b  3  4
2  c  5  6

>>> pd.melt(df, col_level=0, id_vars=["A"], value_vars=["B"])
A variable  value
0  a        B      1
1  b        B      3
2  c        B      5

>>> pd.melt(df, id_vars=[("A", "D")], value_vars=[("B", "E")])
(A, D) variable_0 variable_1  value
0      a          B          E      1
1      b          B          E      3
2      c          B          E      5
zvalue_name (z3) cannot match an element in the DataFrame columns.Úid_varsNÚ
value_varsz)id_vars cannot contain duplicate columns.éÿÿÿÿT)ÚstrictzFThe following id_vars or value_vars are not present in the DataFrame: F)ÚdeepÚ	variable_r   z	var_name=z has z, items, but the dataframe columns only have z levels.z must be a scalar.r   )Úignore_index)ÚnameÚdtypeé   c              3  ó†   #   • U  H7  n[        U[        R                  5      (       + =(       a    UR                  v •  M9     g 7f)N)r   Únpr$   Ú_supports_2d)Ú.0Údts     r   Ú	<genexpr>Úmelt.<locals>.<genexpr>  s-   é € ð &ÚCO¸RŒJ�rœ2Ÿ8™8Ó$Ô$×8¨¯©Ô8Â<ùs   ‚?AÚF©r   )(r   r   r   ÚlenÚget_indexer_forÚget_level_valuesÚanyÚzipÚKeyErrorÚilocÚalgosÚuniqueÚcopyr   r
   ÚnamesÚsetÚranger#   r   r   r   ÚshapeÚpopr$   r'   r   ÚtypeÚtileÚ_valuesÚdtypesÚvaluesÚravelÚ	enumerateÚ_get_level_valuesÚrepeatÚ_constructorÚarangeÚindexÚtake)Úframer   r   Úvar_nameÚ
value_nameÚ	col_levelr"   Úvalue_vars_was_not_noneÚlevelÚlabelsÚidxÚmissingÚlabÚ	not_foundÚmissing_labelsÚiÚnum_rowsÚKÚnum_cols_adjustedÚmdataÚcolÚid_dataÚmcolumnsÚresultÚtakers                            r   Úmeltra   ,   s´  € ðN —]‘]Ó"ÜØ˜:˜,ð '%ð %ó
ð 	
ô ˜w¨	°5·=±=ÓA€GØ(°Ð4ÐÜ! *¨l¸E¿M¹MÓJ€Jô ˆ5�=‰=×(Ñ(¨Ó1Ó2´S¸³\ÓAÜÐDÓEÐEæ–*ØÑ Ø—M‘M×2Ñ2°9Ó=‰Eà—M‘MˆEØÑ%ˆØ×#Ñ# FÓ+ˆØ˜‘)ˆØ�;‰;�=‰=ä*-¨fÀdÒ*KôÚ*K™˜Ìy—Ñ*Kð ñ ô ð"Ø"0Ð!1ð3óð ö #Ø—J‘Jšq¤%§,¢,¨sÓ"3Ð3Ñ4‰Eà—J‘J E�JÐ*‰Eà—
‘
 �
Ð&ˆàÑàŸ™×6Ñ6°yÓAˆŒàÑÜ�e—m‘m¤Z×0Ñ0Ü�5—=‘=×&Ñ&Ó'¬3¬s°5·=±=×3FÑ3FÓ/GÓ+HÓHØ Ÿ=™=×.Ñ.’ä5:¼3¸u¿}¹}×?RÑ?RÓ;SÔ5TÓUÒ5T°˜i¨ s›OÑ5T�ÐU�ð ',§m¡m×&8Ñ&8Ñ&D�—‘×"Ò"È*ð‰Hô 
�h×	Ñ	Ü�e—m‘m¤Z×0Ñ0Ü˜8×$Ñ$Ü ›>�Ü�8‹}œs 5§=¡=Ó1Ó1Ü Ø �x‘k ¤s¨8£} oð 6;Ü;>¸u¿}¹}Ó;MÐ:NÈhðXóð ð 2ô  	 ™{Ð*<Ð=Ó>Ð>à�:ˆà—+‘+�K€HˆaØœC ›LÑ(Ðà*,€EÛˆØ—)‘)˜C“.ˆÜ˜'Ÿ-™-¬¯©×2Ñ2à  1Ó$Ü# W IÐ0AÑ$AÐPTÑU��c“
ô " 'œ]¨2°G·L±LÈÏÉÑV��c“
äŸš §¡Ð2CÓDˆE�#‹Jñ ð Ñ! Z LÑ0€Hà‡{�{�1�~˜Ó¤#ñ &ØCHÇ<Â<ó&÷ #ñ #ô #Ü',¨U¯[©[¸©^Ô'<Ó=Ò'< !�Z‰Zš˜1˜ÔÑ'<Ñ=ÈDñ
ç
‰&ð 	ˆjÒð "ŸM™M×/Ñ/°Ó4ˆˆjÑÜ˜HÖ%‰ˆˆ3Ø—]‘]×4Ñ4°QÓ7×>Ñ>¸xÓHˆˆc‹
ñ &ð ×Ñ ¨xÐÐ8€FæÜ—’œŸ	š	¤# e£*Ó-Ð/@ÓAˆØ—{‘{×'Ñ'¨Ó.ˆŒà€Mùó[ùò. VùòR >s   ÄUÄUÉU$Ñ!U)c                óX  • 0 n/ n[        5       n[        [        [        UR	                  5       5      5      5      nUR                  5        Hl  u  px[        U5      U:w  a  [        S5      eU V	s/ s H  o�U	   R                  PM     n
n	[        U
5      X7'   UR                  U5        UR                  U5      nMn     [        U R                  R                  U5      5      nU H(  n	[        R                  " X	   R                  U5      X9'   M*     U(       a|  [        R                   " [        X4S      5      ["        S9nU H  nU[%        X=   5      -  nM     UR'                  5       (       d'  UR                  5        VVs0 s H
  u  pïXïU   _M     nnnU R)                  X;U-   S9$ s  sn	f s  snnf )aC  
Reshape wide-format data to long. Generalized inverse of DataFrame.pivot.

Accepts a dictionary, ``groups``, in which each key is a new column name
and each value is a list of old column names that will be "melted" under
the new column name as part of the reshape.

Parameters
----------
data : DataFrame
    The wide-format DataFrame.
groups : dict
    {new_name : list_of_columns}.
dropna : bool, default True
    Do not include columns whose entries are all NaN.

Returns
-------
DataFrame
    Reshaped DataFrame.

See Also
--------
melt : Unpivot a DataFrame from wide to long format, optionally leaving
    identifiers set.
pivot : Create a spreadsheet-style pivot table as a DataFrame.
DataFrame.pivot : Pivot without aggregation that can handle
    non-numeric data.
DataFrame.pivot_table : Generalization of pivot that can handle
    duplicate values for one index/column pair.
DataFrame.unstack : Pivot based on the index values instead of a
    column.
wide_to_long : Wide panel to long format. Less flexible but more
    user-friendly than melt.

Examples
--------
>>> data = pd.DataFrame(
...     {
...         "hr1": [514, 573],
...         "hr2": [545, 526],
...         "team": ["Red Sox", "Yankees"],
...         "year1": [2007, 2007],
...         "year2": [2008, 2008],
...     }
... )
>>> data
   hr1  hr2     team  year1  year2
0  514  545  Red Sox   2007   2008
1  573  526  Yankees   2007   2008

>>> pd.lreshape(data, {"year": ["year1", "year2"], "hr": ["hr1", "hr2"]})
      team  year   hr
0  Red Sox  2007  514
1  Yankees  2007  573
2  Red Sox  2008  545
3  Yankees  2008  526
z$All column lists must be same lengthr   )r$   r.   )r:   r/   ÚnextÚiterrB   Úitemsr   r@   r   ÚappendÚunionr   r   Ú
differencer'   r?   ÚonesÚboolr	   ÚallrG   )ÚdataÚgroupsÚdropnar[   Ú
pivot_colsÚall_colsrY   Útargetr9   r\   Ú	to_concatÚid_colsÚmaskÚcÚkÚvs                   r   Úlreshaperx     sg  € ðx €EØ€JÜ!›e€HÜŒD”�f—m‘m“oÓ&Ó'Ó(€AØŸ™ž‰ˆÜˆu‹:˜‹?ÜÐCÓDÐDÙ27Ó8²%¨3˜#‘Y×&Ô&±%ˆ	Ð8ä% iÓ0ˆ‰Ø×Ñ˜&Ô!Ø—>‘> %Ó(Šñ (ô �4—<‘<×*Ñ*¨8Ó4Ó5€GÛˆÜ—W’W˜T™Y×.Ñ.°Ó2ˆ‹
ñ ö Ü�wŠw”s˜5¨A¡Ñ/Ó0¼Ñ=ˆÛˆAØ”E˜%™(“OÑ#ŠDñ à�x‰x�z‰zØ,1¯K©K¬MÔ:ªM¡D A�Q˜$™’Z©MˆEÑ:à×Ñ˜U°jÑ,@ÐÐAÐAùò# 9ùó ;s   Á-F!Å;F&c                óö  • SS jnS	S jn[        U5      (       d  U/nO[        U5      nU R                  R                  U5      R	                  5       (       a  [        S5      e[        U5      (       d  U/nO[        U5      nX   R                  5       R	                  5       (       a  [        S5      e/ n/ n	U H6  n
U" X
XE5      nU	R                  U5        UR                  U" X
X#X´5      5        M8     [        USS9nU R                  R                  U	5      nX   n[        U5      S:X  a   UR                  U5      R                  U5      $ UR                  UR                  5       US9R                  / UQUP5      $ )
aÆ  
Unpivot a DataFrame from wide to long format.

Less flexible but more user-friendly than melt.

With stubnames ['A', 'B'], this function expects to find one or more
group of columns with format
A-suffix1, A-suffix2,..., B-suffix1, B-suffix2,...
You specify what you want to call this suffix in the resulting long format
with `j` (for example `j='year'`)

Each row of these wide variables are assumed to be uniquely identified by
`i` (can be a single column name or a list of column names)

All remaining variables in the data frame are left intact.

Parameters
----------
df : DataFrame
    The wide-format DataFrame.
stubnames : str or list-like
    The stub name(s). The wide format variables are assumed to
    start with the stub names.
i : str or list-like
    Column(s) to use as id variable(s).
j : str
    The name of the sub-observation variable. What you wish to name your
    suffix in the long format.
sep : str, default ""
    A character indicating the separation of the variable names
    in the wide format, to be stripped from the names in the long format.
    For example, if your column names are A-suffix1, A-suffix2, you
    can strip the hyphen by specifying `sep='-'`.
suffix : str, default '\\d+'
    A regular expression capturing the wanted suffixes. '\\d+' captures
    numeric suffixes. Suffixes with no numbers could be specified with the
    negated character class '\\D+'. You can also further disambiguate
    suffixes, for example, if your wide variables are of the form A-one,
    B-two,.., and you have an unrelated column A-rating, you can ignore the
    last one by specifying `suffix='(!?one|two)'`. When all suffixes are
    numeric, they are cast to int64/float64.

Returns
-------
DataFrame
    A DataFrame that contains each stub name as a variable, with new index
    (i, j).

See Also
--------
melt : Unpivot a DataFrame from wide to long format, optionally leaving
    identifiers set.
pivot : Create a spreadsheet-style pivot table as a DataFrame.
DataFrame.pivot : Pivot without aggregation that can handle
    non-numeric data.
DataFrame.pivot_table : Generalization of pivot that can handle
    duplicate values for one index/column pair.
DataFrame.unstack : Pivot based on the index values instead of a
    column.

Notes
-----
All extra variables are left untouched. This simply uses
`pandas.melt` under the hood, but is hard-coded to "do the right thing"
in a typical case.

Examples
--------
>>> np.random.seed(123)
>>> df = pd.DataFrame(
...     {
...         "A1970": {0: "a", 1: "b", 2: "c"},
...         "A1980": {0: "d", 1: "e", 2: "f"},
...         "B1970": {0: 2.5, 1: 1.2, 2: 0.7},
...         "B1980": {0: 3.2, 1: 1.3, 2: 0.1},
...         "X": dict(zip(range(3), np.random.randn(3), strict=True)),
...     }
... )
>>> df["id"] = df.index
>>> df
  A1970 A1980  B1970  B1980         X  id
0     a     d    2.5    3.2 -1.085631   0
1     b     e    1.2    1.3  0.997345   1
2     c     f    0.7    0.1  0.282978   2
>>> pd.wide_to_long(df, ["A", "B"], i="id", j="year")
... # doctest: +NORMALIZE_WHITESPACE
                X  A    B
id year
0  1970 -1.085631  a  2.5
1  1970  0.997345  b  1.2
2  1970  0.282978  c  0.7
0  1980 -1.085631  d  3.2
1  1980  0.997345  e  1.3
2  1980  0.282978  f  0.1

With multiple id columns

>>> df = pd.DataFrame(
...     {
...         "famid": [1, 1, 1, 2, 2, 2, 3, 3, 3],
...         "birth": [1, 2, 3, 1, 2, 3, 1, 2, 3],
...         "ht1": [2.8, 2.9, 2.2, 2, 1.8, 1.9, 2.2, 2.3, 2.1],
...         "ht2": [3.4, 3.8, 2.9, 3.2, 2.8, 2.4, 3.3, 3.4, 2.9],
...     }
... )
>>> df
   famid  birth  ht1  ht2
0      1      1  2.8  3.4
1      1      2  2.9  3.8
2      1      3  2.2  2.9
3      2      1  2.0  3.2
4      2      2  1.8  2.8
5      2      3  1.9  2.4
6      3      1  2.2  3.3
7      3      2  2.3  3.4
8      3      3  2.1  2.9
>>> long_format = pd.wide_to_long(df, stubnames="ht", i=["famid", "birth"], j="age")
>>> long_format
... # doctest: +NORMALIZE_WHITESPACE
                  ht
famid birth age
1     1     1    2.8
            2    3.4
      2     1    2.9
            2    3.8
      3     1    2.2
            2    2.9
2     1     1    2.0
            2    3.2
      2     1    1.8
            2    2.8
      3     1    1.9
            2    2.4
3     1     1    2.2
            2    3.3
      2     1    2.3
            2    3.4
      3     1    2.1
            2    2.9

Going from long back to wide just takes some creative use of `unstack`

>>> wide_format = long_format.unstack()
>>> wide_format.columns = wide_format.columns.map("{0[0]}{0[1]}".format)
>>> wide_format.reset_index()
   famid  birth  ht1  ht2
0      1      1  2.8  3.4
1      1      2  2.9  3.8
2      1      3  2.2  2.9
3      2      1  2.0  3.2
4      2      2  1.8  2.8
5      2      3  1.9  2.4
6      3      1  2.2  3.3
7      3      2  2.3  3.4
8      3      3  2.1  2.9

Less wieldy column names are also handled

>>> np.random.seed(0)
>>> df = pd.DataFrame(
...     {
...         "A(weekly)-2010": np.random.rand(3),
...         "A(weekly)-2011": np.random.rand(3),
...         "B(weekly)-2010": np.random.rand(3),
...         "B(weekly)-2011": np.random.rand(3),
...         "X": np.random.randint(3, size=3),
...     }
... )
>>> df["id"] = df.index
>>> df  # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
   A(weekly)-2010  A(weekly)-2011  B(weekly)-2010  B(weekly)-2011  X  id
0        0.548814        0.544883        0.437587        0.383442  0   0
1        0.715189        0.423655        0.891773        0.791725  1   1
2        0.602763        0.645894        0.963663        0.528895  1   2

>>> pd.wide_to_long(df, ["A(weekly)", "B(weekly)"], i="id", j="year", sep="-")
... # doctest: +NORMALIZE_WHITESPACE
         X  A(weekly)  B(weekly)
id year
0  2010  0   0.548814   0.437587
1  2010  1   0.715189   0.891773
2  2010  1   0.602763   0.963663
0  2011  0   0.544883   0.383442
1  2011  1   0.423655   0.791725
2  2011  1   0.645894   0.528895

If we have many columns, we could also use a regex to find our
stubnames and pass that list on to wide_to_long

>>> stubnames = sorted(
...     set(
...         [
...             match[0]
...             for match in df.columns.str.findall(r"[A-B]\(.*\)").values
...             if match != []
...         ]
...     )
... )
>>> list(stubnames)
['A(weekly)', 'B(weekly)']

All of the above examples have integers as suffixes. It is possible to
have non-integers as suffixes.

>>> df = pd.DataFrame(
...     {
...         "famid": [1, 1, 1, 2, 2, 2, 3, 3, 3],
...         "birth": [1, 2, 3, 1, 2, 3, 1, 2, 3],
...         "ht_one": [2.8, 2.9, 2.2, 2, 1.8, 1.9, 2.2, 2.3, 2.1],
...         "ht_two": [3.4, 3.8, 2.9, 3.2, 2.8, 2.4, 3.3, 3.4, 2.9],
...     }
... )
>>> df
   famid  birth  ht_one  ht_two
0      1      1     2.8     3.4
1      1      2     2.9     3.8
2      1      3     2.2     2.9
3      2      1     2.0     3.2
4      2      2     1.8     2.8
5      2      3     1.9     2.4
6      3      1     2.2     3.3
7      3      2     2.3     3.4
8      3      3     2.1     2.9

>>> long_format = pd.wide_to_long(
...     df, stubnames="ht", i=["famid", "birth"], j="age", sep="_", suffix=r"\w+"
... )
>>> long_format
... # doctest: +NORMALIZE_WHITESPACE
                  ht
famid birth age
1     1     one  2.8
            two  3.4
      2     one  2.9
            two  3.8
      3     one  2.2
            two  2.9
2     1     one  2.0
            two  3.2
      2     one  1.8
            two  2.8
      3     one  1.9
            two  2.4
3     1     one  2.2
            two  3.3
      2     one  2.3
            two  3.4
      3     one  2.1
            two  2.9
c                óÊ   • S[         R                  " U5       [         R                  " U5       U S3nU R                  U R                  R                  R	                  U5         $ )NÚ^Ú$)ÚreÚescaper   ÚstrÚmatch)ÚdfÚstubÚsepÚsuffixÚregexs        r   Úget_var_namesÚ#wide_to_long.<locals>.get_var_nameso  sL   € Ø”R—Y’Y˜t“_Ð%¤b§i¢i°£nÐ%5°f°X¸QÐ?ˆØ�z‰z˜"Ÿ*™*Ÿ.™.×.Ñ.¨uÓ5Ñ6Ð6r   c                ó$  • [        U UUUR                  U5      US9nXc   R                  R                  [        R
                  " X-   5      SSS9Xc'    [        Xc   5      Xc'   UR                  / UQUP5      $ ! [        [        [        4 a     N,f = f)N)r   r   rM   rL   Ú T)r…   )ra   Úrstripr   Úreplacer}   r~   r   Ú	TypeErrorr   ÚOverflowErrorÚ	set_index)r�   r‚   rW   Újr   rƒ   Únewdfs          r   Ú	melt_stubÚwide_to_long.<locals>.melt_stubs  s—   € ÜØØØ!Ø—{‘{ 3Ó'Øñ
ˆð ‘8—<‘<×'Ñ'¬¯	ª	°$±*Ó(=¸rÈÐ'ÐNˆ‰ð	Ü! %¡(Ó+ˆE‰Hð
 �‰˜w ˜w A˜wÓ'Ð'øô	 œ:¤}Ð5ó 	áð	ús   ÁA7 Á7BÂBz,stubname can't be identical to a column namez3the id variables need to uniquely identify each rowr%   )Úaxis)Úon)r‚   r   rƒ   r   r„   r   )r‚   r   rƒ   r   )r   r   r   Úisinr2   r   Ú
duplicatedÚextendrf   r   rh   r/   rŽ   ÚjoinÚmergeÚreset_index)r�   Ú	stubnamesrW   r�   rƒ   r„   r†   r‘   Ú_meltedÚvalue_vars_flattenedr‚   Ú	value_varÚmeltedr   Únews                  r   Úwide_to_longr¡   p  sS  € ô~7ô(ô& ˜	×"Ñ"Ø�K‰	ä˜“Oˆ	à	‡z�z‡��yÓ!×%Ñ%×'Ñ'ÜÐGÓHÐHä˜�?‰?ØˆC‰ä�‹Gˆà	�u×ÑÓ×Ñ×ÑÜÐNÓOÐOà€GØÐÛˆÙ! "¨CÓ8ˆ	Ø×#Ñ# IÔ.Ø�‰‘y ¨1°Ó@ÖAñ ô
 �G !Ñ$€FØ�j‰j×#Ñ#Ð$8Ó9€GØ
‰+€Cä
ˆ1ƒv�ƒ{Ø�}‰}˜QÓ×$Ñ$ VÓ,Ð,à�y‰y˜×+Ñ+Ó-°!ˆyÐ4×>Ñ>¸wÀ¸wÀA¸wÓGÐGr   )r   r   Úreturnr   )NNNÚvalueNT)rK   r   rM   r   r"   rj   r¢   r   )T)rl   r   rm   Údictrn   rj   r¢   r   )r‰   z\d+)r�   r   rƒ   r   r„   r   r¢   r   )$Ú
__future__r   r}   Útypingr   Únumpyr'   Úpandas.util._decoratorsr   Úpandas.core.dtypes.commonr   r   Úpandas.core.dtypes.concatr   Úpandas.core.dtypes.missingr	   Úpandas.core.algorithmsÚcoreÚ
algorithmsr6   Úpandas.core.indexes.apir
   Úpandas.core.reshape.concatr   Úpandas.core.tools.numericr   Úcollections.abcr   Úpandas._typingr   r   r   r   ra   rx   r¡   © r   r   Ú<module>rµ      s  ðÝ "ã 	Ý  ã å .÷õ 4Ý ,ç &Ð &Ý .Ý -Ý 0æÝ(å+å ôñ ˆHÓð ØØØ"ØØðiØðið
 ðið ðið ôió ðiñX ˆHÓõSBó ðSBñl ˆHÓàAGðsHØðsHØ),ðsHØ;>ðsHàôsHó ñsHr   