Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pandas/core/reshape/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pandas/core/reshape/__pycache__/merge.cpython-312.pyc

�

Mٜg���Z�dZddlmZddlmZmZddlZddlmZddl	m
Z
mZmZm
Z
ddlZddlZddlZddlmZmZmZmZddlmZdd	lmZmZmZmZm Z m!Z!m"Z"m#Z#dd
l$m%Z%ddl&m'Z'm(Z(m)Z)ddl*m+Z+dd
l,m-Z-ddl.m/Z/ddl0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=ddl>m?Z?m@Z@ddlAmBZBmCZCddlDmEZEmFZFddlGmHZHmIZImJZJmKZKmLZLddlMmNcmOZPddlQmRZRmSZSmTZTddlUmVZVddlWmNcmXZYddlZm[Z[m\Z\ddl]m^Z^ddl_m`Z`ddlambZbmcZce
rddlGmdZdddlemfZfddlQmgZgddlhmiZiej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�ej�e�je�je�je�je�je�j
iZ�e�jej�urej�e�e�j<e�jeTeJeCfZ�e(d�e'e^d��											d;																											d<d ���Z�										d=																									d>d!�Z�				d?d"�Z�								d@																	dAd#�Z�												dB																							dCd$�Z�Gd%�d&�Z�		dD									dEd'�Z�		dD									dFd(�Z�												dGd)�Z�Gd*�d+e��Z�dHd,�Z�Gd-�d.e��Z�								dId/�Z�dJd0�Z�						dKd1�Z�	dL									dMd2�Z�	dN							dOd3�Z�						dPd4�Z�								dQd5�Z�										dRd6�Z�dSd7�Z�dSd8�Z�dTd9�Z�								dUd:�Z�y)Vz
SQL-style merge routines
�)�annotations)�Hashable�SequenceN)�partial)�
TYPE_CHECKING�Literal�cast�final)�	Timedelta�	hashtable�join�lib)�is_range_indexer)�AnyArrayLike�	ArrayLike�
IndexLabel�JoinHow�MergeHow�Shape�Suffixes�npt)�
MergeError)�Appender�Substitution�cache_readonly)�find_stack_level)�ExtensionDtype)�find_common_type)
�ensure_int64�
ensure_object�is_bool�
is_bool_dtype�is_float_dtype�
is_integer�is_integer_dtype�is_list_like�	is_number�is_numeric_dtype�is_object_dtype�is_string_dtype�needs_i8_conversion)�CategoricalDtype�DatetimeTZDtype)�ABCDataFrame�	ABCSeries)�isna�na_value_for_dtype)�
ArrowDtype�Categorical�Index�
MultiIndex�Series)�ArrowExtensionArray�BaseMaskedArray�ExtensionArray)�StringDtype)�ensure_wrapped_if_datetimelike�
extract_array)�
_merge_doc)�
default_index)�get_group_index�is_int64_overflow_possible)�	DataFrame)�groupby)�
DatetimeArray)�
FrozenListz!
left : DataFrame or named Series)�indentsc
��t|�}
t|�}|dk(rt|
||||||||	|||
��St|
|||||||||	||��}|j|
��S)N�cross)
�on�left_on�right_on�
left_index�right_index�sort�suffixes�	indicator�validate�copy)
�howrHrIrJrKrLrMrNrOrP�rQ)�_validate_operand�_cross_merge�_MergeOperation�
get_result)�left�rightrRrHrIrJrKrLrMrNrQrOrP�left_df�right_df�ops                �D/usr/local/lib/python3.12/site-packages/pandas/core/reshape/merge.py�merger^�s���" ��%�G� ��'�H�
�g�~�������!�#������

�
	
��������!�#�����

���}�}�$�}�'�'�c���|s|s|�|�|�td��dtj���}|jdi|di��}|jdi|di��}|gx}}t	||d||||||||
||	��
}
|
|=|
S)z,
    See merge.__doc__ with how='cross'
    zMCan not pass on, right_on, left_on or set right_index=True or left_index=True�_cross_��inner)rRrHrIrJrKrLrMrNrOrPrQ�)r�uuid�uuid4�assignr^)rXrYrHrIrJrKrLrMrNrQrOrP�	cross_col�ress              r]rUrU�s���&	������
�>��
�
�	
�
�$�*�*�,��(�I��4�;�;�(�)�Q��(�D��E�L�L�*�I�q�>�*�E�#��$�G�h�
��
��
�����
����
��C�	�I���Jr_c
�@��g}t|ttf�s|g}|j|d��}d}t	�fd�|D��r�j|d��}|j
j
|j|j��D]H\}}|��}	n	�j|j|�}	|||	�}
||
|<|j'|
��Jddlm}||d	�
�}|j|djd��}||fS#t$r�|jj�}
|
�jD�cgc]}|t|
�vs�|��ncc}wc}z}|j|��}
t!t#|
��|
_|j'|
�Y��wxYw)z�
    groupby & merge; we are always performing a left-by type operation

    Parameters
    ----------
    by: field to group
    left: DataFrame
    right: DataFrame
    merge_pieces: function for merging
    F�rMNc3�:�K�|]}|�jv���y�w�N��columns)�.0�itemrYs  �r]�	<genexpr>z%_groupby_and_merge.<locals>.<genexpr>s�����
0�R�T�4�5�=�=� �R�s�)�axisrnr��concatT)�ignore_index)rorQ)�
isinstance�list�tuplerB�all�_grouper�get_iterator�
_selected_objrs�take�indices�KeyErrorro�tolist�set�reindex�range�len�index�append�pandas.core.reshape.concatru)�byrXrY�merge_pieces�pieces�lby�rby�key�lhs�rhs�lcols�r�cols�mergedru�results  `             r]�_groupby_and_merger��s�����F��b�4��-�(��T��
�,�,�r��,�
&�C�CG�C��
0�R�
0�0��m�m�B�U�m�+���L�L�-�-�c�.?�.?�c�h�h�-�O���S��;��C�	
��j�j����S�!1�2���c�3�'����r�
��
�
�f��+P�22�
�F��
.�F�
�^�^�F�1�I�$5�$5�E�^�
B�F��3�;���/�
����*�*�,���5�=�=�P�=�a�A�S��Z�<O��=��P�P�����T��2��$�S��[�1����
�
�f�%��
�s%�D	�	2F�;E
�E
�AF�Fc
�������	�
�d��	����fd��
|�
|�td��|�it|t�r|g}t|�j	|j
�}
t
|
�dk7rt|
�d���t|||�
fd��\}}|S|�it|t�r|g}t|�j	|j
�}
t
|
�dk7rt|
�d���t|||�
fd��\}}|S�
||�}|S)	a)

    Perform a merge for ordered data with optional filling/interpolation.

    Designed for ordered data like time series data. Optionally
    perform group-wise merge (see examples).

    Parameters
    ----------
    left : DataFrame or named Series
    right : DataFrame or named Series
    on : label or list
        Field names to join on. Must be found in both DataFrames.
    left_on : label or list, or array-like
        Field names to join on in left DataFrame. Can be a vector or list of
        vectors of the length of the DataFrame to use a particular vector as
        the join key instead of columns.
    right_on : label or list, or array-like
        Field names to join on in right DataFrame or vector/list of vectors per
        left_on docs.
    left_by : column name or list of column names
        Group left DataFrame by group columns and merge piece by piece with
        right DataFrame. Must be None if either left or right are a Series.
    right_by : column name or list of column names
        Group right DataFrame by group columns and merge piece by piece with
        left DataFrame. Must be None if either left or right are a Series.
    fill_method : {'ffill', None}, default None
        Interpolation method for data.
    suffixes : list-like, default is ("_x", "_y")
        A length-2 sequence where each element is optionally a string
        indicating the suffix to add to overlapping column names in
        `left` and `right` respectively. Pass a value of `None` instead
        of a string to indicate that the column name from `left` or
        `right` should be left as-is, with no suffix. At least one of the
        values must not be None.

    how : {'left', 'right', 'outer', 'inner'}, default 'outer'
        * left: use only keys from left frame (SQL: left outer join)
        * right: use only keys from right frame (SQL: right outer join)
        * outer: use union of keys from both frames (SQL: full outer join)
        * inner: use intersection of keys from both frames (SQL: inner join).

    Returns
    -------
    DataFrame
        The merged DataFrame output type will be the same as
        'left', if it is a subclass of DataFrame.

    See Also
    --------
    merge : Merge with a database-style join.
    merge_asof : Merge on nearest keys.

    Examples
    --------
    >>> from pandas import merge_ordered
    >>> df1 = pd.DataFrame(
    ...     {
    ...         "key": ["a", "c", "e", "a", "c", "e"],
    ...         "lvalue": [1, 2, 3, 1, 2, 3],
    ...         "group": ["a", "a", "a", "b", "b", "b"]
    ...     }
    ... )
    >>> df1
      key  lvalue group
    0   a       1     a
    1   c       2     a
    2   e       3     a
    3   a       1     b
    4   c       2     b
    5   e       3     b

    >>> df2 = pd.DataFrame({"key": ["b", "c", "d"], "rvalue": [1, 2, 3]})
    >>> df2
      key  rvalue
    0   b       1
    1   c       2
    2   d       3

    >>> merge_ordered(df1, df2, fill_method="ffill", left_by="group")
      key  lvalue group  rvalue
    0   a       1     a     NaN
    1   b       1     a     1.0
    2   c       2     a     2.0
    3   d       2     a     3.0
    4   e       3     a     3.0
    5   a       1     b     NaN
    6   b       1     b     1.0
    7   c       2     b     2.0
    8   d       2     b     3.0
    9   e       3     b     3.0
    c
�J��t||��������}|j�S)N)rHrIrJrN�fill_methodrR)�
_OrderedMergerW)	�x�yr\r�rRrIrHrJrNs	   ������r]�_mergerzmerge_ordered.<locals>._merger�s3���
�
�
�����#��	
���}�}��r_z*Can only group either left or right framesrz not found in left columnsc����||�Srmrd�r�r�r�s  �r]�<lambda>zmerge_ordered.<locals>.<lambda>�s
���'�RS�UV�-r_z not found in right columnsc����||�Srmrdr�s  �r]r�zmerge_ordered.<locals>.<lambda>�s�����1�
r_)�returnrA)	�
ValueErrorrw�strr��
differenceror�r�r�)rXrYrHrIrJ�left_by�right_byr�rNrR�checkr��_r�s  ```  ```   @r]�
merge_orderedr�+s���P����x�3��E�F�F����g�s�#��i�G��G��'�'����5���u�:��?��e�W�$>�?�@�@�&�w��e�=W�X�	����M�
�	��h��$� �z�H��H�
�(�(����7���u�:��?��e�W�$?�@�A�A�&��e�T�#=�
�	���
�M���u�%���Mr_c�V�t||||||||||	|
d|||
��}|j�S)ax"
    Perform a merge by key distance.

    This is similar to a left-join except that we match on nearest
    key rather than equal keys. Both DataFrames must be sorted by the key.

    For each row in the left DataFrame:

      - A "backward" search selects the last row in the right DataFrame whose
        'on' key is less than or equal to the left's key.

      - A "forward" search selects the first row in the right DataFrame whose
        'on' key is greater than or equal to the left's key.

      - A "nearest" search selects the row in the right DataFrame whose 'on'
        key is closest in absolute distance to the left's key.

    Optionally match on equivalent keys with 'by' before searching with 'on'.

    Parameters
    ----------
    left : DataFrame or named Series
    right : DataFrame or named Series
    on : label
        Field name to join on. Must be found in both DataFrames.
        The data MUST be ordered. Furthermore this must be a numeric column,
        such as datetimelike, integer, or float. On or left_on/right_on
        must be given.
    left_on : label
        Field name to join on in left DataFrame.
    right_on : label
        Field name to join on in right DataFrame.
    left_index : bool
        Use the index of the left DataFrame as the join key.
    right_index : bool
        Use the index of the right DataFrame as the join key.
    by : column name or list of column names
        Match on these columns before performing merge operation.
    left_by : column name
        Field names to match on in the left DataFrame.
    right_by : column name
        Field names to match on in the right DataFrame.
    suffixes : 2-length sequence (tuple, list, ...)
        Suffix to apply to overlapping column names in the left and right
        side, respectively.
    tolerance : int or Timedelta, optional, default None
        Select asof tolerance within this range; must be compatible
        with the merge index.
    allow_exact_matches : bool, default True

        - If True, allow matching with the same 'on' value
          (i.e. less-than-or-equal-to / greater-than-or-equal-to)
        - If False, don't match the same 'on' value
          (i.e., strictly less-than / strictly greater-than).

    direction : 'backward' (default), 'forward', or 'nearest'
        Whether to search for prior, subsequent, or closest matches.

    Returns
    -------
    DataFrame

    See Also
    --------
    merge : Merge with a database-style join.
    merge_ordered : Merge with optional filling/interpolation.

    Examples
    --------
    >>> left = pd.DataFrame({"a": [1, 5, 10], "left_val": ["a", "b", "c"]})
    >>> left
        a left_val
    0   1        a
    1   5        b
    2  10        c

    >>> right = pd.DataFrame({"a": [1, 2, 3, 6, 7], "right_val": [1, 2, 3, 6, 7]})
    >>> right
       a  right_val
    0  1          1
    1  2          2
    2  3          3
    3  6          6
    4  7          7

    >>> pd.merge_asof(left, right, on="a")
        a left_val  right_val
    0   1        a          1
    1   5        b          3
    2  10        c          7

    >>> pd.merge_asof(left, right, on="a", allow_exact_matches=False)
        a left_val  right_val
    0   1        a        NaN
    1   5        b        3.0
    2  10        c        7.0

    >>> pd.merge_asof(left, right, on="a", direction="forward")
        a left_val  right_val
    0   1        a        1.0
    1   5        b        6.0
    2  10        c        NaN

    >>> pd.merge_asof(left, right, on="a", direction="nearest")
        a left_val  right_val
    0   1        a          1
    1   5        b          6
    2  10        c          7

    We can use indexed DataFrames as well.

    >>> left = pd.DataFrame({"left_val": ["a", "b", "c"]}, index=[1, 5, 10])
    >>> left
       left_val
    1         a
    5         b
    10        c

    >>> right = pd.DataFrame({"right_val": [1, 2, 3, 6, 7]}, index=[1, 2, 3, 6, 7])
    >>> right
       right_val
    1          1
    2          2
    3          3
    6          6
    7          7

    >>> pd.merge_asof(left, right, left_index=True, right_index=True)
       left_val  right_val
    1         a          1
    5         b          3
    10        c          7

    Here is a real-world times-series example

    >>> quotes = pd.DataFrame(
    ...     {
    ...         "time": [
    ...             pd.Timestamp("2016-05-25 13:30:00.023"),
    ...             pd.Timestamp("2016-05-25 13:30:00.023"),
    ...             pd.Timestamp("2016-05-25 13:30:00.030"),
    ...             pd.Timestamp("2016-05-25 13:30:00.041"),
    ...             pd.Timestamp("2016-05-25 13:30:00.048"),
    ...             pd.Timestamp("2016-05-25 13:30:00.049"),
    ...             pd.Timestamp("2016-05-25 13:30:00.072"),
    ...             pd.Timestamp("2016-05-25 13:30:00.075")
    ...         ],
    ...         "ticker": [
    ...                "GOOG",
    ...                "MSFT",
    ...                "MSFT",
    ...                "MSFT",
    ...                "GOOG",
    ...                "AAPL",
    ...                "GOOG",
    ...                "MSFT"
    ...            ],
    ...            "bid": [720.50, 51.95, 51.97, 51.99, 720.50, 97.99, 720.50, 52.01],
    ...            "ask": [720.93, 51.96, 51.98, 52.00, 720.93, 98.01, 720.88, 52.03]
    ...     }
    ... )
    >>> quotes
                         time ticker     bid     ask
    0 2016-05-25 13:30:00.023   GOOG  720.50  720.93
    1 2016-05-25 13:30:00.023   MSFT   51.95   51.96
    2 2016-05-25 13:30:00.030   MSFT   51.97   51.98
    3 2016-05-25 13:30:00.041   MSFT   51.99   52.00
    4 2016-05-25 13:30:00.048   GOOG  720.50  720.93
    5 2016-05-25 13:30:00.049   AAPL   97.99   98.01
    6 2016-05-25 13:30:00.072   GOOG  720.50  720.88
    7 2016-05-25 13:30:00.075   MSFT   52.01   52.03

    >>> trades = pd.DataFrame(
    ...        {
    ...            "time": [
    ...                pd.Timestamp("2016-05-25 13:30:00.023"),
    ...                pd.Timestamp("2016-05-25 13:30:00.038"),
    ...                pd.Timestamp("2016-05-25 13:30:00.048"),
    ...                pd.Timestamp("2016-05-25 13:30:00.048"),
    ...                pd.Timestamp("2016-05-25 13:30:00.048")
    ...            ],
    ...            "ticker": ["MSFT", "MSFT", "GOOG", "GOOG", "AAPL"],
    ...            "price": [51.95, 51.95, 720.77, 720.92, 98.0],
    ...            "quantity": [75, 155, 100, 100, 100]
    ...        }
    ...    )
    >>> trades
                         time ticker   price  quantity
    0 2016-05-25 13:30:00.023   MSFT   51.95        75
    1 2016-05-25 13:30:00.038   MSFT   51.95       155
    2 2016-05-25 13:30:00.048   GOOG  720.77       100
    3 2016-05-25 13:30:00.048   GOOG  720.92       100
    4 2016-05-25 13:30:00.048   AAPL   98.00       100

    By default we are taking the asof of the quotes

    >>> pd.merge_asof(trades, quotes, on="time", by="ticker")
                         time ticker   price  quantity     bid     ask
    0 2016-05-25 13:30:00.023   MSFT   51.95        75   51.95   51.96
    1 2016-05-25 13:30:00.038   MSFT   51.95       155   51.97   51.98
    2 2016-05-25 13:30:00.048   GOOG  720.77       100  720.50  720.93
    3 2016-05-25 13:30:00.048   GOOG  720.92       100  720.50  720.93
    4 2016-05-25 13:30:00.048   AAPL   98.00       100     NaN     NaN

    We only asof within 2ms between the quote time and the trade time

    >>> pd.merge_asof(
    ...     trades, quotes, on="time", by="ticker", tolerance=pd.Timedelta("2ms")
    ... )
                         time ticker   price  quantity     bid     ask
    0 2016-05-25 13:30:00.023   MSFT   51.95        75   51.95   51.96
    1 2016-05-25 13:30:00.038   MSFT   51.95       155     NaN     NaN
    2 2016-05-25 13:30:00.048   GOOG  720.77       100  720.50  720.93
    3 2016-05-25 13:30:00.048   GOOG  720.92       100  720.50  720.93
    4 2016-05-25 13:30:00.048   AAPL   98.00       100     NaN     NaN

    We only asof within 10ms between the quote time and the trade time
    and we exclude exact matches on time. However *prior* data will
    propagate forward

    >>> pd.merge_asof(
    ...     trades,
    ...     quotes,
    ...     on="time",
    ...     by="ticker",
    ...     tolerance=pd.Timedelta("10ms"),
    ...     allow_exact_matches=False
    ... )
                         time ticker   price  quantity     bid     ask
    0 2016-05-25 13:30:00.023   MSFT   51.95        75     NaN     NaN
    1 2016-05-25 13:30:00.038   MSFT   51.95       155   51.97   51.98
    2 2016-05-25 13:30:00.048   GOOG  720.77       100     NaN     NaN
    3 2016-05-25 13:30:00.048   GOOG  720.92       100     NaN     NaN
    4 2016-05-25 13:30:00.048   AAPL   98.00       100     NaN     NaN
    �asof)
rHrIrJrKrLr�r�r�rNrR�	tolerance�allow_exact_matches�	direction)�
_AsOfMergerW)rXrYrHrIrJrKrLr�r�r�rNr�r�r�r\s               r]�
merge_asofr��sJ��v
��
�
�����
������/��
�B�"�=�=�?�r_c�H�eZdZUdZdZded<ded<ded<ded	<d
ed<d
ed<d
ed
<ded<d
ed<ded<ded<ded<ded<ded<										d,																									d-d�Z						d.d�Zd/d�Ze											d0d��Z
d1d2d�Ze	ed3d ���Z
e							d4d!��Ze	d5d"��Ze	d6d#��Ze									d7d$��Z		d8d%�Ze			d9d&��Ze		d:									d;d'��Ze			d<d(��Ze	d=d)��Zd*�Ze	d>d+��Zy)?rVz�
    Perform a database (SQL) merge operation between two DataFrame or Series
    objects using either columns as keys or their row indexes
    r^�JoinHow | Literal['asof']rR�IndexLabel | NonerHz!Sequence[Hashable | AnyArrayLike]rIrJ�boolrKrLrMrrNrQ�
str | boolrO�
str | NonerPzlist[Hashable]�
join_names�list[ArrayLike]�right_join_keys�left_join_keysNc
�2�t|�}
t|�}|
x|_|_|x|_|_||_t
j|�|_|
|_	|	xs|dk(|_
||_||_||_
t|�stdt!|�����t|�stdt!|�����|
j"j$|j"j$k7r<d|
j"j$�d|j"j$�d�}t'|��|j)||�\|_|_|j/�\|_|_|_}}|r |jj7|�|_|r |jj7|�|_|j9|j0|j2�|j;|j0�|j=�|�|j?|�yy)N�outerz/left_index parameter must be of type bool, not z0right_index parameter must be of type bool, not z0Not allowed to merge between different levels. (z levels on the left, z on the right)) rTrX�	orig_leftrY�
orig_rightrR�com�maybe_make_listrHrNrMrKrLrOr!r��typero�nlevelsr�_validate_left_right_onrIrJ�_get_merge_keysr�r�r��_drop_labels_or_levels�_maybe_require_matching_dtypes�_validate_tolerance�_maybe_coerce_merge_keys�_validate_validate_kwd)�selfrXrYrRrHrIrJrKrLrMrNrOrP�_left�_right�msg�	left_drop�
right_drops                  r]�__init__z_MergeOperation.__init__�s���"�$�'��"�5�)��%*�*��	�D�N�'-�-��
�T�_�����%�%�b�)��� ��
��*�C�7�N��	�$���&���"����z�"��A�$�z�BR�AS�T��
��{�#��B�4��CT�BU�V��
�
�=�=� � �F�N�N�$:�$:�:���M�M�)�)�*�*?��>�>�)�)�*�.�:�
�
�S�/�!�&*�&B�&B�7�H�&U�#���d�m�
� � �"�
	
���� ��O�����	�	�8�8��C�D�I�����:�:�:�F�D�J��+�+�D�,?�,?��AU�AU�V�� � ��!4�!4�5�	
�%�%�'�
���'�'��1� r_c��yrmrd)r�r�r�s   r]r�z._MergeOperation._maybe_require_matching_dtypes/s��	
r_c��yrmrd)r�r�s  r]r�z#_MergeOperation._validate_tolerance5s��r_c	�|�|jdd}|jdd}t|jj|jj|j�\}}|�Tt|t
|��s?|jj||ddddd��}	|j|	|	j��}||_|�Tt|t
|��s?|jj||ddddd��}
|j|
|
j��}||_ddlm
}||_||_|||gd|�	�}|S)
z?
        reindex along index and concat along columns.
        NrbFT)rsrQ�
only_slice�
allow_dups�use_na_proxy)�axesrrt)rsrQ)rXrY�_items_overlap_with_suffix�
_info_axisrNrr��_mgr�reindex_indexer�_constructor_from_mgrr�r��pandasruro)
r��
join_index�left_indexer�
right_indexerrQrXrY�llabels�rlabels�lmgr�rmgrrur�s
             r]�_reindex_and_concatz#_MergeOperation._reindex_and_concat9sE���y�y��|���
�
�1�
��5��I�I� � �$�*�*�"7�"7����
�����#�,<�\�3�t�9�,U��9�9�,�,�������!�-��D��-�-�d����-�C�D���
��$�-=��3�u�:�.
��:�:�-�-�������!�.��D��/�/��4�9�9�/�E�E� ���!������
���u�
�A�D�9���
r_c��|jr3|j|j|j�\|_|_|j	�\}}}|j||||��}|j
||j��}|jr|j|�}|j|||�|j|�|j
|d��S)NrS)�methodr^)rO�_indicator_pre_mergerXrY�_get_join_infor��__finalize__�_merge_type�_indicator_post_merge�_maybe_add_join_keys�_maybe_restore_index_levels)r�rQr�r�r�r�s      r]rWz_MergeOperation.get_resultrs����>�>�$(�$=�$=�d�i�i����$T�!�D�I�t�z�26�2E�2E�2G�/�
�L�-��)�)���m�$�*�
���$�$�T�$�2B�2B�$�C���>�>��/�/��7�F��!�!�&�,�
�F��(�(��0��"�"�4��"�8�8r_c��t|jt�r|jSt|jt�r|jrdSdSt	d��)N�_mergez<indicator option can only accept boolean or string arguments)rwrOr�r�r��r�s r]�_indicator_namez_MergeOperation._indicator_name�sK���d�n�n�c�*��>�>�!�
�����
-�#�~�~�8�7�4�7��N��
r_c�h�|jj|j�}dD]}||vs�td|����|j|vrtd��|j	�}|j	�}d|d<|djd�|d<d|d<|djd�|d<||fS)	N)�_left_indicator�_right_indicatorzECannot use `indicator=True` option when data contains a column named z:Cannot use name of an existing column for indicator columnrbr��int8�r�)ro�unionr�r�rQ�astype)r�rXrYro�is     r]r�z$_MergeOperation._indicator_pre_merge�s����,�,�$�$�U�]�]�3��8�A��G�|� �4�45�3�8���9����7�*��L��
��y�y�{���
�
���"#��
��"&�'8�"9�"@�"@��"H��
��$%�� �!�$)�*<�$=�$D�$D�V�$L�� �!��U�{�r_c�D�|djd�|d<|djd�|d<t|d|dzgd���||j<||jjj	gd��||j<|jddgd��}|S)	Nr�rr�)rbr��)�
categories)�	left_only�
right_only�bothrb)�labelsrs)�fillnar3r��cat�rename_categories�drop)r�r�s  r]r�z%_MergeOperation._indicator_post_merge�s���$*�+<�$=�$D�$D�Q�$G�� �!�%+�,>�%?�%F�%F�q�%I��!�"�'2�
�%�
&��0B�)C�
C� �(
��t�#�#�$�(.�� � �(
�

�#��� C�D�	�t�#�#�$����%6�8J�$K�RS��T���
r_c�l�g}t|j|j|j�D]n\}}}|jj|�s�#|jj|�s�?||k(s�E||jjvs�^|j|��p|r|j|d��yy)a
        Restore index levels specified as `on` parameters

        Here we check for cases where `self.left_on` and `self.right_on` pairs
        each reference an index level in their respective DataFrames. The
        joined columns corresponding to these pairs are then restored to the
        index of `result`.

        **Note:** This method has side effects. It modifies `result` in-place

        Parameters
        ----------
        result: DataFrame
            merge result

        Returns
        -------
        None
        T��inplaceN)�zipr�rIrJr��_is_level_referencer�r��namesr��	set_index)r�r��names_to_restore�name�left_key�	right_keys      r]r�z+_MergeOperation._maybe_restore_index_levels�s���*��),��O�O�T�\�\�4�=�=�*
�%�D�(�I����2�2�8�<��O�O�7�7����	�)����� 2� 2�2� �'�'��-�#*
�&����-�t��<�r_c�:�d}d}td�|jD��sJ�t|j|j|j
�}t
|�D�]�\}\}}	}
t|	|
�s�d\}}||vr�|�|��||jvrm|�|�dn|dk(j�}|r�|j|}||j|j|jk7r�|j|j}n�||jvr�|�|�dn|dk(j�}|rp|j|}||j|j|jk7r8|j|j}n|j|}|j|}|�|���@|�||j}
n?|�|}
n:t|d��}t|j�}t!j"|||��}
|�||j}n?|�|}n:t|d��}t|j�}t!j"|||��}|�+|dk(j�rt%|�}|j}n�|�+|dk(j�rt%|
�}|
j}n�t%|
�}|�|dk(}|j'||�}t)|
j|jg�}|
jj*dk(r4|jj*dk(r|j*d	k(r|j}|j-|�r#|j/|||j0�
�||<��|j3|�r�t5|j0t6�r_||_|j0j:D�cgc]$}||k7r|j0j=|�n|��&}}|j?|d�����t%||��|_���|jA||xsd
|��|����ycc}w)Nc3�<K�|]}t|t����y�wrm)rw�_known�rpr�s  r]rrz7_MergeOperation._maybe_add_join_keys.<locals>.<genexpr>�s����F�2E�Q�:�a��(�2E�s�)NNF���T��
extract_numpy��
fill_value�M�O)�dtyper�r)r�key_)!rzr�r
r�rIrJ�	enumerate�_should_fillrX�anyr�r�_valuesrYr<r1�algos�take_ndr4�wherer�kind�_is_label_reference�_constructor_slicedr�rrwr5rr�get_level_valuesr
�insert)r�r�r�r��left_has_missing�right_has_missing�keysr�r�lname�rname�	take_left�
take_right�lvals�lfill�rvals�taker�rfill�key_col�result_dtype�	mask_left�
level_name�idx_lists                       r]r�z$_MergeOperation._maybe_add_join_keys�s�� �� ���F�$�2E�2E�F�F�F�F��4�?�?�D�L�L�$�-�-�@��'0���#�A�#��e�U���u�-��$.�!�I�z��v�~��+�}�/H��t�y�y�(�+�3�$0�#7�!&�&2�b�&8�%=�%=�%?�-�,�)-�)=�)=�a�)@�J�%�d�|�1�1�T�Y�Y�t�_�5J�5J�J�,0�I�I�d�O�,C�,C�	�����+�,�4�$1�#8�!&�&3�r�&9�%>�%>�%@�.�-�(,�(;�(;�A�(>�I�%�d�|�1�1�T�Z�Z��5E�5K�5K�K�-1�Z�Z��-=�-E�-E�
�!�/�/��2�	�!�1�1�!�4�
��$�
�(>��$�"�4�L�0�0�E�!�)�%�E�!.�i�t� L�I�.�y���?�E�!�M�M�)�\�e�T�E��%�"�4�L�0�0�E�"�*�&�E�*�*�D�I�E�.�u�{�{�;�E�!�M�M�%��5�Q�E� �+���1C�0H�0H�0J�#�E�l�G�#(�;�;�L�"�.�M�R�4G�3L�3L�3N�#�E�l�G�#(�;�;�L�#�E�l�G�#�/�$0�B�$6�	�")�-�-��
�E�"B��#3�U�[�[�%�+�+�4N�#O�L����(�(�C�/�!�K�K�,�,��3�(�-�-��4�(/�}�}���-�-�d�3�#)�#=�#=��|�6�<�<�$>�$�F�4�L��/�/��5�!�&�,�,�
�;�'+���
/5�l�l�.@�.@�	$�/A�
� *�T�1�#�L�L�9�9�*�E�!(�)�/A�	!�$��(�(��4�(�@�',�W�4�'@����M�M�!�T�%7�t�A�3�Z��A�M(7��v$s�&)Pc��|jdk7sJ�t|j|j|j|j��S)�return the join indexersr�)rMrR)rR�get_join_indexersr�r�rMr�s r]�_get_join_indexersz"_MergeOperation._get_join_indexers_s@��
�x�x�6�!�!�!� �����!5�!5�D�I�I�4�8�8�
�	
r_c�R�|jj}|jj}|jrJ|jr>|j
dk7r/|j
||j
d|j��\}}}�n�|jr8|j
dk(r)t|||j|j��\}}}�n]|jr8|j
dk(r)t|||j|j��\}}}�n|j�\}}|jrSt|j�dkDr|j|||d��}n�|�|j�}n�|j|�}n�|jrx|j
dk(r|j|||d��}nvt|j�dkDr|j|||d��}nH|�|j�}n5|j|�}n#|�t|�n
t|�}t!|�}|||fS)	Nr�T�rR�return_indexersrMrXrkrYr�rR)rXr�rYrKrLrRr
rM�_left_join_on_indexr�r�r?r��_create_join_indexrQr~r>)r��left_ax�right_axr�r�r��ns       r]r�z_MergeOperation._get_join_infois����)�)�/�/���:�:�#�#���?�?�t�/�/�D�H�H��4F�6=�l�l��d�h�h��4�9�9�7C�7�3�J��m��
�
�$�(�(�f�"4�6I���4�#6�#6�T�Y�Y�7�3�J��m��_�_����W�!4�6I��'�4�#7�#7�d�i�i�7�3�J�
�|�-1�,C�,C�,E�)�\�=�����t�y�y�>�A�%�!%�!8�!8�� �$�#�	"9�"�J�#�*�!)����J�!)���}�!=�J�����8�8�v�%�!%�!8�!8�� �$�"�	"9�"�J�����_�q�(�!%�!8�!8� ��%�"�	"9�"�J�"�)�!(����J�!(���l�!;�J�$0�$8�C��L�c�,�>O��*�1�-�
��<��6�6r_c� �|j|dfvr\t|t�sL|dk(}tj|�r2t|jd��}|jt|g��}|�|j�S|j|�S)a�
        Create a join index by rearranging one index to match another

        Parameters
        ----------
        index : Index
            index being rearranged
        other_index : Index
            used to supply values not found in index
        indexer : np.ndarray[np.intp] or None
            how to rearrange index
        how : str
            Replacement is only necessary if indexer based on other_index.

        Returns
        -------
        Index
        r�rF)�compat)rRrwr5�npr!r1rr�r4rQr~)r�r��other_index�indexerrR�maskrs       r]rEz"_MergeOperation._create_join_index�sx��4�8�8��W�~�%�j��j�.Q��b�=�D��v�v�d�|�/����E�J�
����U�J�<�%8�9���?��:�:�<���z�z�'�"�"r_c�N�
��g}g}g}g}g}|j|jc�
��
fd�}�fd�}t|j��ryt|j��rct|j|j�D�]=\}}	t
|d��}t
|	d��}	||�r�tt|�}|j|�||	�r3tt|	�}	|j|	�|jd���tt|	�}	|	�2|j�j|	��|j|	���|j�jj�|j�jj���||	�sqtt|	�}	|	�!|j�j|	��n%|j�jj�|�8||	k(r3|j|	�n!tt|	�}	|j|	�|�Ctt|�}|j�
j|��|j|����|j�
jj�|j�
jj���@�n�t|j��rV|jD]�}
||
�r@t
|
d��}
tt|
�}
|j|
�|jd��Ktt|
�}
|j�
j|
��|j|
���t|jjt �rut|jjj"|jjj$�D��cgc] \}}|jj'|���"}}}�n�|jjjg}�nit|j��rS|jD]�}
t
|
d��}
||
�r3tt|
�}
|j|
�|jd��Ktt|
�}
|j�j|
��|j|
���t|jjt �rtt|jjj"|jjj$�D��cgc] \}}|jj'|���"}}}n!|jjjg}|||||fScc}}wcc}}w)zj
        Returns
        -------
        left_keys, right_keys, join_names, left_drop, right_drop
        c�V��t|t�xrt|�t��k(Srm�rwrr�)r�rXs �r]r�z1_MergeOperation._get_merge_keys.<locals>.<lambda>�s!���J�q�&�1�I�c�!�f��D�	�6I�Ir_c�V��t|t�xrt|�t��k(SrmrQ)r�rYs �r]r�z1_MergeOperation._get_merge_keys.<locals>.<lambda>�s!���J�q�&�1�J�c�!�f��E�
�6J�Jr_TrN)rXrY�_anyrIrJr
r<r	rr�r�_get_label_or_level_valuesr�r"rrwr5�levels�codesr~)r��	left_keys�
right_keysr�r�r��is_lkey�is_rkey�lk�rk�k�lev�	lev_codesrXrYs             @@r]r�z_MergeOperation._get_merge_keys�s����&(�	�&(�
�%'�
�%'�
�$&�	��i�i������e�I��J�������$�t�}�}�"5��d�l�l�D�M�M�:���B�"�2�T�:��"�2�T�:���2�;��i��,�B��$�$�R�(��r�{�!�)�R�0��"�)�)�"�-�"�)�)�$�/�"�(�B�/���>�&�-�-�e�.N�.N�r�.R�S�&�-�-�b�1�'�-�-�e�k�k�.A�.A�B�&�-�-�e�k�k�.>�.>�?�"�2�;�"�(�B�/���>�&�-�-�e�.N�.N�r�.R�S�'�-�-�e�k�k�.A�.A�B��>�b�B�h�&�-�-�b�1�!�)�R�0��"�)�)�"�-��~�"�(�B�/��!�(�(��)H�)H��)L�M�"�)�)�"�-�"�(�(����);�);�<�"�)�)�$�*�*�/�/�:�[;�\�$�,�,�
��\�\���1�:�%�a�t�<�A��Y��*�A��$�$�Q�'��%�%�d�+��X�q�)�A��$�$�T�%D�%D�Q�%G�H��%�%�a�(�"��$�*�*�*�*�J�7�+.��
�
�(�(�/�/����1A�1A�1G�1G�+��+���Y��K�K�$�$�Y�/�+���#�j�j�.�.�6�6�7�
�
�$�-�-�
 ��]�]��!�!�4�8���1�:��Y��*�A��%�%�a�(��%�%�d�+��X�q�)�A��%�%�e�&F�&F�q�&I�J��%�%�a�(�#��$�)�)�/�/�:�6�+.��	�	���.�.��	�	���0E�0E�+��+���Y��K�K�$�$�Y�/�+���"�Y�Y�_�_�4�4�5�	��*�j�)�Z�G�G��?��,s�%V�
%V!c�
�t|j|j|j�D�]:\}}}t	|�rt	|�rt	|�st	|�r�5t|d��}t|d��}t
|jt�}t
|jt�}t|j�xst|j�}t|j�xst|j�}|r5|r3tt|�}tt|�}|j|�r"��|s|rn|j|jk(r��2d|j�d|j�d|�d�}t|j��rt|j��r�|jj|jjk(r���t
|jt �r�t
|jt �sht#|j|jg�}	t
|	t �r%|	j%�}
|
j'||	d��}n�|j)|	�}n�t
|jt �rgt#|j|jg�}	t
|	t �r%|	j%�}
|
j'||	d��}n|j)|	�}t+|j�r�t-|j�r�t/j0d	�
�5|j)|j�}ddd�t/j2|�}|k(}
|
|j5�s$t7j8dt:t=������t-|j�r�t+|j�r�t/j0d	�
�5|j)|j�}ddd�t/j2|�}|k(}
|
|j5�s$t7j8dt:t=�����:t?j@|d�
�t?j@|d�
�k(�r���l|rtC|j�stC|j�r|r�n�|rt|j�st|j�r_|r]t?j@|d�
�}t?j@|d�
�}gd�}gd�}||vr||vr�n||vr||vs
||v�r||v�rtE|��tG|j�r tG|j�stE|��tG|j�s tG|j�rtE|��t
|jtH�r%t
|jtH�stE|��t
|jtH�s%t
|jtH�rtE|��t
|jtH�rt
|jtH�s2|jjdk(r|jjdk(r��w|jjdk(r$|jjdk(rtE|��|jjdk(r$|jjdk(rtE|��t|j�rt|j�r��||jJjLvrv|r$tt|�jNjntP}|jJjS�|_%|jJ|j)|�|jJ|<||jTjLvs���|r$tt|�jNjntP}|jTjS�|_*|jT|j)|�|jT|<��=y#1swY��xYw#1swY��pxYw)NTrzYou are trying to merge on � and z columns for key 'z2'. If you wish to proceed you should use pd.concatF�rrQ�ignore)�invalidzjYou are merging on int and float columns where the float values are not equal to their int representation.)�
stacklevel)�skipna)�integerz
mixed-integer�boolean�empty)�string�unicode�mixed�bytesrir�m)+r
r�r�r�r�r<rwrr,r)r*r	r3�#_categories_match_up_to_permutationr(r&rr�construct_array_type�_from_sequencer�r%r#rK�errstate�isnanrz�warnings�warn�UserWarningrr�infer_dtyper"r�r+r-rXror��objectrQrY)r�r[r\r�	lk_is_cat�	rk_is_cat�lk_is_object_or_string�rk_is_object_or_stringr��ct�com_cls�castedrN�match�
inferred_left�inferred_right�
bool_types�string_types�typs                   r]r�z(_MergeOperation._maybe_coerce_merge_keysSsV�� �����!5�!5�t���
�L�B��D��B���B���R��S��W���r��6�B��r��6�B�"�2�8�8�-=�>�I�"�2�8�8�-=�>�I�%4�R�X�X�%>�&�/����C�"�&5�R�X�X�%>�&�/����C�"��Y��+�r�*���+�r�*���9�9�"�=���i�����R�X�X�%��.�b�h�h�Z�u�R�X�X�J�G� �6�!S�U�
� ����)�.>�r�x�x�.H��8�8�=�=�B�H�H�M�M�1���b�h�h��7�
��H�H�n�A�*�2�8�8�R�X�X�*>�?�B�!�"�n�5�"$�"9�"9�";��$�3�3�B�b�u�3�M���Y�Y�r�]������.�9�)�2�8�8�R�X�X�*>�?�B�!�"�n�5�"$�"9�"9�";��$�3�3�B�b�u�3�M���Y�Y�r�]��$�B�H�H�-�.����2J����X�6�"$���2�8�8�!4��	7��H�H�R�L�=�D��&�L�E� ��;�?�?�,� �
�
�I�(�'7�'9���!�"�(�(�+�0@����0J����X�6�"$���2�8�8�!4��	7��H�H�R�L�=�D��&�L�E� ��;�?�?�,� �
�
�I�(�'7�'9����?�?�2�e�4�����u�9���)�]�2�8�8�-D��b�h�h�'�,B��)�-=�b�h�h�-G� ����*�/E� #����5� A�
�!$����E�!B��M�
�O��!�J�.�>�Z�3O��"�\�1�n�L�6X�"�l�2�}�L�7X�$�S�/�)�%�R�X�X�.�7J�2�8�8�7T� ��o�%�(����2�7J�2�8�8�7T� ��o�%��B�H�H�o�6�z����/�@�!��o�%�����/�:�z����/�@�!��o�%��2�8�8�_�5��r�x�x��9��(�(�-�-�3�&�2�8�8�=�=�C�+?�������#�%�"�(�(�-�-�3�*>� ��o�%������#�%�"�(�(�-�-�3�*>� ��o�%� ����*��r�x�x�/H���t�y�y�(�(�(�@I�d�;��+�6�6�<�<�v�� �I�I�N�N�,��	�"&�)�)�D�/�"8�"8��"=��	�	�$���t�z�z�)�)�)�@I�d�;��+�6�6�<�<�v��!�Z�Z�_�_�.��
�#'�:�:�d�#3�#:�#:�3�#?��
�
�4� �k
�B7�6��(7�6�s�6a+�.a8�+a5	�8b	c
��tj|�}tj|�}|j�� |��|��|jr|jrd\}}�nV|jrtd��|jrtd��|jj}|jj}|j|�}t|�dk(r+td|�d|�d|j�d|j����|j|d	�
�jr|j|d	�
�jstdt|�����|x}}�n[|j�B|�|�td��|js|jrtd
��|jx}}�n
|��|jrtd��|js
|�td��t|�}|jr�t|�|jjjk7rt!d��dg|z}n�|��|jrtd��|js
|�td��t|�}|jr=t|�|jjjk7rt!d��dg|z}t|�t|�k7rt!d��||fS)N)rdrdz&Must pass right_on or right_index=Truez$Must pass left_on or left_index=Truerz>No common columns to perform merge on. Merge options: left_on=z, right_on=z
, left_index=z, right_index=rcrCzData columns not unique: zSCan only pass argument "on" OR "left_on" and "right_on", not a combination of both.zYCan only pass argument "on" OR "left_index" and "right_index", not a combination of both.z:Can only pass argument "left_on" OR "left_index" not both.z&Must pass "right_on" OR "right_index".zDlen(left_on) must equal the number of levels in the index of "right"z<Can only pass argument "right_on" OR "right_index" not both.z$Must pass "left_on" OR "left_index".zDlen(right_on) must equal the number of levels in the index of "left"z%len(right_on) must equal len(left_on))r�r�rHrKrLrrXrorY�intersectionr�r
�	is_unique�reprr�r�r�)r�rIrJ�	left_cols�
right_cols�common_colsrHs       r]r�z'_MergeOperation._validate_left_right_ons����%�%�g�.���&�&�x�0���7�7�?�w��8�3C����4�#3�#3�$*�!������ �!I�J�J��!�!� �!G�H�H�!�I�I�-�-�	�!�Z�Z�/�/�
�'�4�4�Z�@���{�#�q�(�$�2�29��;$�$,�:�.&�&*�o�o�%6�7'�'+�'7�'7�&8�	:���"���{���@�J�J�%�?�?�;�G�?�D�N�N�$�'@��k�AR�@S�%T�U�U�%0�0��(�
�W�W�
 ��"�h�&:� �A������$�"2�"2� �D���"&���(�G�h�
�
 ���� �P����#�#��(8� �!I�J�J��G��A�����w�<�4�:�:�#3�#3�#;�#;�;�$�<���!�6�A�:��
�
!���� �R����?�?�w�� �!G�H�H��H�
�A�����x�=�D�I�I�O�O�$;�$;�;�$�;��� �&�1�*���x�=�C��L�(��D�E�E��� � r_c�&�|jr!|jjj}n)t	j
|j�j}|jr!|jjj}n)t	j
|j�j}|dvr*|s
|std��|std��|std��y|dvr|std��y|dvr|std��y|d	vrytd
|�d���)N)�
one_to_onez1:1zQMerge keys are not unique in either left or right dataset; not a one-to-one mergezAMerge keys are not unique in left dataset; not a one-to-one mergezBMerge keys are not unique in right dataset; not a one-to-one merge)�one_to_manyz1:mzBMerge keys are not unique in left dataset; not a one-to-many merge)�many_to_onezm:1zCMerge keys are not unique in right dataset; not a many-to-one merge)�many_to_manyzm:m�"z�" is not a valid argument. Valid arguments are:
- "1:1"
- "1:m"
- "m:1"
- "m:m"
- "one_to_one"
- "one_to_many"
- "many_to_one"
- "many_to_many")rKr�r�r�r5�from_arraysr�rLr�r�rr�)r�rP�left_unique�right_uniques    r]r�z&_MergeOperation._validate_validate_kwd`s=���?�?��.�.�.�.�8�8�K�$�0�0��1D�1D�E�O�O�K�����?�?�0�0�:�:�L�%�1�1�$�2F�2F�G�Q�Q�L��,�,��|� �?���� �W��� � �X��� �
�/�
/�� �X����
�/�
/�� �.��� ��0�
0����H�:�	#�	#��
r_)
rcNNNFFT��_x�_yFN)rX�DataFrame | SeriesrYr�rRr�rH� IndexLabel | AnyArrayLike | NonerIr�rJr�rKr�rLr�rMr�rNrrOr�rPr�r��None�r�r�r�r�r�r��r�r�r�r�)
r�r4r��npt.NDArray[np.intp] | Noner�r�rQ�bool | Noner�rA�T�rQr�r�rA)r�r�)rXrArYrAr�ztuple[DataFrame, DataFrame])r�rAr�rA)r�rAr�r�)r�rAr�r�r�r�r�r�)r��?tuple[npt.NDArray[np.intp] | None, npt.NDArray[np.intp] | None])r�zFtuple[Index, npt.NDArray[np.intp] | None, npt.NDArray[np.intp] | None])rX)
r�r4rLr4rMr�rRrr�r4)r�zWtuple[list[ArrayLike], list[ArrayLike], list[Hashable], list[Hashable], list[Hashable]])r�r�)rPr�r�r�)�__name__�
__module__�__qualname__�__doc__r��__annotations__r�r�r�r
r�rWrr�r�r�r�r�r?r�rEr�r�r�r�rdr_r]rVrV�s���
�K�	"�"���/�.�/�/�����
�J���
�J�������$�$�#�#�*1�/3�48�59� �!��)� %�#�L2� �L2�"�L2�'�	L2�

-�L2�2�
L2�3�L2��L2��L2��L2��L2��L2��L2�
�L2�\
�-�
�@O�
�	
�
�
��6��6�2�6�3�	6�
�6�
�
6��6�p9�(����������&/��	$����6�
��
��)=��)=�V�rB��rB�2�rB�3�	rB�

�rB��rB�h
�	H�
��<7�	O�<7��<7�|��%#��%#��%#�-�	%#�
�%#�
�
%#��%#�N�@H�
�@H��@H�D�|@��|@�|L!�\�8��8r_rVc�T����t��t��k(sJd��t�d�}t�d�}|dk(r |dvr
t�S�s5|dvr1t|d�S|dk(r |dvr
t�S�s|dvrt|d�St��d	kDrO���fd
�tt���D�}t	|�}d�|D�\}}	}
t||	t
|
���\}}n
�d}�d}t|�}
t|�}|
jr>|jr2|
js|jr|
j||d���\}}}n%t|
j|j�|�\}}|�t|t|
��rd
}|�t|t|��rd
}||fS)a�

    Parameters
    ----------
    left_keys : list[ndarray, ExtensionArray, Index, Series]
    right_keys : list[ndarray, ExtensionArray, Index, Series]
    sort : bool, default False
    how : {'inner', 'outer', 'left', 'right'}, default 'inner'

    Returns
    -------
    np.ndarray[np.intp] or None
        Indexer into the left_keys.
    np.ndarray[np.intp] or None
        Indexer into the right_keys.
    z0left_keys and right_keys must be the same lengthr)rXrc)rYr�T)rYrc)rXr�Frbc3�F�K�|]}t�|�|������y�w�rkN)�_factorize_keys)rprHrWrXrMs  ���r]rrz$get_join_indexers.<locals>.<genexpr>�s-�����
�*��
�I�a�L�*�Q�-�d�C�C�*�s�!c3�2K�|]}t|����y�wrm�rxrs  r]rrz$get_join_indexers.<locals>.<genexpr>������5�f��T�!�W�f���rAN)r��_get_empty_indexer� _get_no_sort_one_missing_indexerr�r
�_get_join_keysryr4�is_monotonic_increasingr�r
�get_join_indexers_non_uniquer"r)rWrXrMrR�left_n�right_n�mapped�zipped�llab�rlab�shape�lkey�rkeyrXrYr��lidx�ridxs```               r]r>r>�s����,�y�>�S����:�9�:��
��1��
�F��*�Q�-� �G�
��{��#�#�%�'�'��#�!3�3�3�G�T�B�B�	�A���$�$�%�'�'��#�!2�2�3�F�E�B�B��9�~���
��3�y�>�*�
���f���5�f�5���d�E�$�D�$��e��d�C�
��d���|���!�}����;�D��$�K�E�	
�$�$��)�)�
�^�^�u����	�	�%�S�$�T�	�R�
��4��1��L�L�%�-�-��s�
�
��d���,�T�3�t�9�=�����,�T�3�u�:�>�����:�r_c�J�t|||��\}}}|dk(r tj||||��\}}||fS|dk(r tj||||��\}}||fS|dk(r tj||||��\}}||fS|dk(rtj|||�\}}fS)aW
    Get join indexers for left and right.

    Parameters
    ----------
    left : ArrayLike
    right : ArrayLike
    sort : bool, default False
    how : {'inner', 'outer', 'left', 'right'}, default 'inner'

    Returns
    -------
    np.ndarray[np.intp]
        Indexer into left.
    np.ndarray[np.intp]
        Indexer into right.
    rkrXrYrcr�)r��libjoin�left_outer_join�
inner_join�full_outer_join)	rXrYrMrRr�r��countr�r�s	         r]r�r��s���.(��e�$�?��D�$��
�f�}��,�,�T�4��T�J�
��d���:��


����,�,�T�4��T�J�
��d�
��:��	

����'�'��d�E��E�
��d���:��

����,�,�T�4��?�
��d���:�r_c�x�dd�}||�}|j}|j}|j}	|D]�}
|
|jvr|}|}n|}|}|jj|
�}
|j|
}|j|
}|�|}nt	j
||d��}||gz}||gz}|	|
gz}	��|||	fS)a�
    *this is an internal non-public method*

    Returns the levels, labels and names of a multi-index to multi-index join.
    Depending on the type of join, this method restores the appropriate
    dropped levels of the joined multi-index.
    The method relies on lindexer, rindexer which hold the index positions of
    left and right, where a join was feasible

    Parameters
    ----------
    left : MultiIndex
        left index
    right : MultiIndex
        right index
    dropped_level_names : str array
        list of non-common level names
    join_index : Index
        the index of the join between the
        common levels of left and right
    lindexer : np.ndarray[np.intp]
        left indexer
    rindexer : np.ndarray[np.intp]
        right indexer

    Returns
    -------
    levels : list of Index
        levels of combined multiindexes
    labels : np.ndarray[np.intp]
        labels of combined multiindexes
    names : List[Hashable]
        names of combined multiindex levels

    c��t|t�r|Stj|jg|jg��S)N)r)rwr5r�r"r)r�s r]�_convert_to_multiindexz@restore_dropped_levels_multijoin.<locals>._convert_to_multiindex9s0���e�Z�(��L��)�)�5�=�=�/�%�*�*��N�Nr_rr)r�r4r�r5)rUrVrr�r#r$)rXrY�dropped_level_namesr��lindexer�rindexerr��join_levels�
join_codesr��dropped_level_name�idxrM�name_idx�restore_levelsrV�
restore_codess                 r]� restore_dropped_levels_multijoinr�
s���XO�(�
�3�J��#�#�K��!�!�J��!�!�J�2������+��C��G��C��G��9�9�?�?�#5�6�����H�-���	�	�(�#���?�!�M�!�M�M�%��R�H�M�"�^�$4�4���=�/�1�
��#5�"6�6�
�/2�2�
�J�.�.r_c�^�eZdZdZ								d																					dd�Zddd�Zy)	r��
ordered_mergeNc
�R�|	|_tj|||||||||
|d��y)NT)rHrIrKrLrJrRrNrM)r�rVr�)r�rXrYrHrIrJrKrLrNr�rRs           r]r�z_OrderedMerge.__init__is@��'���� � ������!�#�����	!�	
r_c�>�|j�\}}}|jdk(r5|�d}ntj|�}|�d}n2tj|�}n|j�|}|}nt	d��|j||||��}|j
|||�|S)N�ffillz#fill_method must be 'ffill' or NonerS)r�r�r��
ffill_indexerr�r�r�)r�rQr�r�r��left_join_indexer�right_join_indexerr�s        r]rWz_OrderedMerge.get_result�s���26�2E�2E�2G�/�
�L�-�
���w�&��#�$(�!�$+�$9�$9�,�$G�!��$�%)�"�%,�%:�%:�=�%I�"�
�
�
�
%� ,��!.���B�C�C��)�)��)�+=�D�*�
��	
�!�!�&�,�
�F��
r_)NNNFFr�Nr�)rXr�rYr�rHr�rIr�rJr�rKr�rLr�rNrr�r�rRr�r�r�r�r�)r�r�r�r�r�rWrdr_r]r�r�fs���!�K�!%�%)�&*� �!�)�"&�)0�
� �
�"�
�
�	
�
#�
�$�

��
��
��
� �
�'�
�
�
�8r_r�c�0�d|�d�}tt|d�S)N�
asof_join_�
_on_X_by_Y)�getattrr�)r�rs  r]�_asof_by_functionr��s��
�	�{�*�-�D��7�D�$�'�'r_c���eZdZdZ													d																							d	d�Z�fd�Z						d
d�Zdd�Z						dd�Zd
d�Z	�xZ
S)r��
asof_mergec
�B�||_|	|_|
|_|
|_||_||_|j
dvrt
d|j
����t|j�sd|j��}t
|��tj||||||||||d��y)N)�backward�forward�nearestzdirection invalid: z,allow_exact_matches must be boolean, passed )rHrIrJrKrLrRrNr�)
r�r�r�r�r�r�rr!r�r�)r�rXrYrHrIrJrKrLr�r�r�rNrRr�r�r�r�s                 r]r�z_AsOfMerge.__init__�s���$������ ��
�"���#6�� �"����>�>�!C�C��2�4�>�>�2B�C�D�D��t�/�/�0���2�2�3�5�
��S�/�!����������!�#����	�	
r_c���t�|�||�\}}t|�dk7r|jst	d��t|�dk7r|j
st	d��|jr/t
|jjt�rt	d��|j
r/t
|jjt�rt	d��|j�;|j�|j�t	d��|jx|_|_
|j�|j�t	d��|j�|j�t	d��|js�|d	}t
|t�r
|j}n�||jj vr%|jj#|�jn$|jjj%|�}n |jjj}|j
s�|d	}t
|t�r
|j}n�||jj vr%|jj#|�jn$|jjj%|�}n |jjj}t'|�s!t'|�st)|�st)|�r$t	d
t+|��dt+|��d���|j��t-|j�s|jg|_t-|j�s|jg|_
t|j�t|j�k7rt	d
��|jt/|�z}|jt/|�z}||fS)Nrbzcan only asof on a key for leftz can only asof on a key for rightzleft can only have one indexzright can only have one indexz(Can only pass by OR left_by and right_byzmissing left_byzmissing right_byrzIncompatible merge dtype, raz$, both sides must have numeric dtypez,left_by and right_by must be the same length)�superr�r�rKrrLrwrXr�r5rYr�r�r�rrrorTr)r)r*r�r&rx)r�rIrJ�	left_on_0�lo_dtype�
right_on_0�ro_dtype�	__class__s       �r]r�z"_AsOfMerge._validate_left_right_on�s���!�G�;�G�X�N�����w�<�1��T�_�_��>�?�?��x�=�A��d�&6�&6��?�@�@��?�?�z�$�)�)�/�/�:�F��;�<�<����
�4�:�:�+;�+;�Z� H��<�=�=��7�7���|�|�'�4�=�=�+D� �!K�L�L�+/�7�7�2�D�L�4�=��<�<��D�M�M�$=��.�/�/��<�<�#��
�
�(=��/�0�0������
�I��)�V�,�$�?�?��!�D�I�I�$5�$5�5��I�I�8�8��C�I�I������9�9�)�D���y�y���,�,�H����!�!��J��*�f�-�%�+�+��"�T�Z�Z�%7�%7�7��J�J�9�9�*�E�K�K����)�)�:�:�:�F���z�z�'�'�-�-�H�
�H�%��x�(��x�(��x�(��,�T�(�^�,<�E���>�"�"F�H��
��<�<�#�����-� $���~�����
�
�.�!%�����
��4�<�<� �C��
�
�$6�6� �!O�P�P��l�l�T�'�]�2�G��}�}�t�H�~�5�H��� � r_c�<�dd�}tt||��D]\}\}}||||��|jr!|jjj
}n|d}|jr!|jjj
}n|d}|||d�y)Nc��|j|jk7r�t|jt�rWt|jt�r=d|�dt|j��dt|j��d�}t	|��d|�dt|j��dt|j��d�}t	|��y)Nzincompatible merge keys [z] raz), both sides category, but not equal onesz, must be the same type)rrwr,r�r)rXrYr�r�s    r]�_check_dtype_matchzE_AsOfMerge._maybe_require_matching_dtypes.<locals>._check_dtype_match2s����z�z�U�[�[�(��d�j�j�*:�;�
��K�K�!1�A�4�A�3�b��d�j�j�9I�8J�%�����,�-�-V�X��!��o�%�4�A�3�b��d�j�j�9I�8J�%�����,�-�-D�F��!��o�%�+)r_rr)rXrrYrr��int)rr
rKrXr�r"rLrY)	r�r�r�r�r�r[r\�lt�rts	         r]r�z)_AsOfMerge._maybe_require_matching_dtypes-s���
	&�2%�S���%I�J�K�A�x��B��r�2�q�)�K��?�?������(�(�B���#�B�������!�!�)�)�B� ��$�B��2�r�1�%r_c�B�|j���|jr!|jjj}n|d}d|j�dt|j���}t|j�s(t|t�rk|jjdvrSt|jtj�st|��|jtd�krtd��yt|j�r;t!|j�st|��|jdkrtd��yt#|j�r;t%|j�st|��|jdkrtd��ytd��y)Nrzincompatible tolerance z, must be compat with type �mMrztolerance must be positivez'key must be integer, timestamp or float)r�rKrXr�r"r�rr+rwr7r&�datetime�	timedeltarrr%r$r#r')r�r�r�r�s    r]r�z_AsOfMerge._validate_toleranceZsX���>�>�%�����Y�Y�_�_�,�,��#�B�'��*�$�.�.�)9�:�!�"�(�(�^�,�.�
�
#�2�8�8�,��2�2�3����
�
��8M�!�$�.�.�(�2D�2D�E�$�S�/�)��>�>�I�a�L�0�$�%A�B�B�1�"�"�(�(�+�!�$�.�.�1�$�S�/�)��>�>�A�%�$�%A�B�B�&� ����)� ����0�$�S�/�)��>�>�A�%�$�%A�B�B�&�!�!J�K�K�C&r_c��t|�js6t|�j�rt	d|�d���t	|�d���t|t�r|j�}t|j�r|jd�}|St|t�r|j}|St|t�r|j�}|S)Nz"Merge keys contain null values on z sidez keys must be sorted�i8)r4r�r0r!r�rwr7�_maybe_convert_datelike_arrayr+r�viewr8�_datar9�to_numpy)r��values�sides   r]�_convert_values_for_libjoinz&_AsOfMerge._convert_values_for_libjoins����V�}�4�4��F�|���!� �#E�d�V�5�!Q�R�R���v�%9�:�;�;��f�1�2��9�9�;�F��v�|�|�,��[�[��&�F��
����
0��\�\�F��
�
���
/��_�_�&�F�
�
r_c	��|jr |jjjn|jd}|j
r |jjjn|jd}|j|jk(sJ�|j}|��t|j�s(t|t�r�|jjdvr�t|�}|jjdvrWt|t�r!|jjj }nt#|�j }|j%|�}|j&}|j)|d�}|j)|d�}|j*��A|jr%|j
r|j}|j}n|jdd}|jdd}t-t/|��D�cgc]}t1||||d����}}t/|�d	k(r|dd}	|dd	}
n^|D�cgc]}t3j4|dd
���}}t7d�|D��}
t9||
dd��}t/|d�}|d|}	||d}
t;|	�}	t;|
�}
t=|j>�}||||	|
|j@|�St=|j>�}|||dd|j@|d�Scc}wcc}w)
r=rNr�rXrYrFrkrbr�c3�&K�|]	}|d���y�w)r�Nrd)rprns  r]rrz0_AsOfMerge._get_join_indexers.<locals>.<genexpr>�s����3�F�q�a��d�F�s�)r�rM�xnull)!rKrXr�r"r�rLrYr�rr�r+rwr7r&r�
pyarrow_dtype�unitr;�as_unit�_valuerr�r�r�r�rK�concatenateryr?rr�r�r�)r��left_values�right_valuesr�rr�r�rHr��left_by_values�right_by_valuesrn�arrsr��group_index�left_len�funcs                 r]r?z_AsOfMerge._get_join_indexers�s��
(,���D�I�I�O�O�#�#�D�<O�<O�PR�<S�	�)-�(8�(8�D�J�J���$�$�d�>R�>R�SU�>V�	�
� � �L�$6�$6�6�6�6��N�N�	�� �#�;�#4�#4�5��;�(;�<��%�%�*�*�d�2�%�i�0�	��$�$�)�)�T�1�"�+�/B�C�*�0�0�>�>�C�C��=�k�J�O�O�� )� 1� 1�$� 7�I�%�,�,�	��6�6�{�F�K���7�7��g�N���<�<�#����4�#3�#3�!%�!4�!4��"&�"6�"6��!%�!4�!4�Q�r�!:��"&�"6�"6�q��"<���s�>�2�3�
�4�A� �"�1�%�#�A�&���
4�

���>�"�a�'�!'���1���"(��)�A�,��7=�>�v�!����q��!�u�-�v��>��3�F�3�3��-���E�����~�a�0�1��!,�Y�h�!7��"-�h�i�"8��)�.�9�N�*�?�;�O�%�T�^�^�4�D�������(�(��
�
�%�T�^�^�4�D�������(�(����
��M��?s�9L�9L)
NNNFFNNNr�r�NTr�)rXr�rYr�rHr�rIr�rJr�rKr�rLr�rNrrRzLiteral['asof']r�r�r�r�r�r�r�r�)r�rr�r�r��
np.ndarray�r��1tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]])r�r�r�r�r�r�r�r�rr?�
__classcell__)r�s@r]r�r��s�����K�!%�%)�&*� �!����)�%��$(�#�!1
� �1
�"�1
�
�	1
�
#�1
�$�
1
��1
��1
��1
��1
�"�1
� �!1
�"
�#1
�fN!�`+&�-�+&�@O�+&�	
�+&�Z#L�J�"��*-��	��4`r_r�c�L�������fd�t�j�D�}t|�}d�|D�\}}}�r/tt	t
j|�j��}n"d�}tt	|�j��}t��D]n\}	}
�j|	dk(}|j�s�)|
||	||	dz
k(}|jdk(s|d|dk7s
||	xxdz
cc<||	dz
||	|<�pt||t|���\}
}|
|fS)Nc3�n�K�|],}t�j|j�|������.y�wr�)r�rUr")rprHr��	join_keysrMs  ���r]rrz*_get_multiindex_indexer.<locals>.<genexpr>	s7������%�A�	����Q��/�/��1��D�I�I�%�s�25c3�2K�|]}t|����y�wrmr�rs  r]rrz*_get_multiindex_indexer.<locals>.<genexpr>	r�r�c�*�|jddd��S)Nr�FT��subokrQ)r�)�as r]r�z)_get_multiindex_indexer.<locals>.<lambda>		s��1�8�8�D��D�8�Ar_rrbr)
r�r�r
rx�maprKr~rVrr!�sizer�ry)rr�rMr�r��rcodes�lcodesr��i8copyr��join_keyrNrr�r�s```            r]�_get_multiindex_indexerr#�s�����u�}�}�%��F��&�\�F�5�f�5��F�F�E���c�"�'�'�6�5�;�;�7�8��A���c�&�%�+�+�.�/��!��+���8��{�{�1�~��#���8�8�:�����e�A�h��l�2�3�A��v�v��{�!�A�$�!�A�$�,��a��A�
��#�A�h��l�F�1�I�d�O�,� ����e��d�C�J�D�$���:�r_c��tjgtj��tjgtj��fS)zReturn empty join indexers.�r)rK�array�intprdr_r]r�r�	s2��	����2�7�7�#�
����2�7�7�#��r_c��tj|tj��}tj|dtj��}|r||fS||fS)a�
    Return join indexers where all of one side is selected without sorting
    and none of the other side is selected.

    Parameters
    ----------
    n : int
        Length of indexers to create.
    left_missing : bool
        If True, the left indexer will contain only -1's.
        If False, the right indexer will contain only -1's.

    Returns
    -------
    np.ndarray[np.intp]
        Left indexer
    np.ndarray[np.intp]
        Right indexer
    r%r)r�rr)rK�aranger'�full)rH�left_missingr��idx_missings    r]r�r�%	sG��,
�)�)�A�R�W�W�
%�C��'�'��b����@�K���C������r_c�,�t|t�rt|||��\}}n|d}|j}t	|||��\}}}tj||||��\}	}
|st|�t|	�k7r|j|	�}||	|
fS|d|
fS)Nrkr)	rwr5r#r"r�r�r�r�r~)rFrGrrMr�r�rrr�r�r�r�s            r]rDrDB	s����(�J�'�,�Y��t�L�
��d�
��|������!0��t�$�!G��H�i��")�"9�"9��)�U��#��L�-��s�7�|�s�<�0�0��\�\�,�/�
��<��6�6��D�-�'�'r_c���t|jt�rt|jt�s@tj|jd�rltj|jd�rLtd|�j
|�\}}td|�j}td|�j}�n�t|jt�r�t|jt�rz|j|jk(rat|t�sJ�t|t�sJ�|j|�}t|j�}t|j�}�n�t|t��r�|j|jk(�r�t|jt�rt|j�s4t|jt ��r�|jj"dv�r�ddl}ddlm}t+|�}|j,}|j,}|j/|j0|j0z�j3�j5�}|j7|j8t;|�d�j=�j?t@jBd��|j7|j8t;|d�d�j=�j?t@jBd��t+|jD�}	}}|r,|jDj=d�	�}
tG|
||�\}}|jHdkDra|dk(}|jK�}|dk(}
|
jK�}|rtAjL|||	�|rtAjL||
|	�|	d
z
}	|||	fSt|tN�svt|jt�r6tQ|jjR�s=t|j�r|r&|jU�\}}|jU�\}}tW|j�rc|j|jk(rJtAjX|t@jZ��}tAjX|t@jZ��}t]||�\}}}|t_t+|�t+|���}t|tN�rat|tN�sJ�|ja|jb|jd��}|ja|jb|jd��}n�t|tf�r�t|tf�sJ�|ja|j=d
|jjR�
�|ji���}|ja|j=d
|jjR�
�|ji���}n"|ja|�}|ja|�}|jtAjt@jB�k(sJ|j��|jtAjt@jB�k(sJ|j��|jk�}	|r*|jljo�}
tG|
||�\}}|dk(}|jK�}|dk(}
|
jK�}|s|r7|rtAjL|||	�|rtAjL||
|	�|	d
z
}	|||	fS)a�
    Encode left and right keys as enumerated types.

    This is used to get the join indexers to be used when merging DataFrames.

    Parameters
    ----------
    lk : ndarray, ExtensionArray
        Left key.
    rk : ndarray, ExtensionArray
        Right key.
    sort : bool, defaults to True
        If True, the encoding is done such that the unique elements in the
        keys are sorted.

    Returns
    -------
    np.ndarray[np.intp]
        Left (resp. right if called with `key='right'`) labels, as enumerated type.
    np.ndarray[np.intp]
        Right (resp. left if called with `key='right'`) labels, as enumerated type.
    int
        Number of unique elements in union of left and right labels.

    See Also
    --------
    merge : Merge DataFrame or named Series objects
        with a database-style join.
    algorithms.factorize : Encode the object as an enumerated type
        or categorical variable.

    Examples
    --------
    >>> lk = np.array(["a", "c", "b"])
    >>> rk = np.array(["a", "c"])

    Here, the unique values are `'a', 'b', 'c'`. With the default
    `sort=True`, the encoding will be `{0: 'a', 1: 'b', 2: 'c'}`:

    >>> pd.core.reshape.merge._factorize_keys(lk, rk)
    (array([0, 2, 1]), array([0, 2]), 3)

    With the `sort=False`, the encoding will correspond to the order
    in which the unique elements first appear: `{0: 'a', 1: 'c', 2: 'b'}`:

    >>> pd.core.reshape.merge._factorize_keys(lk, rk, sort=False)
    (array([0, 1, 2]), array([0, 1]), 3)
    rrC)�pyarrow�
pyarrow_numpyrNrFrS)�zero_copy_onlyrbr%)rN)�na_valuer)8rwrr-r�is_np_dtyper	�_ensure_matching_resos�_ndarrayr,r3�_encode_with_my_categoriesrrVr9r2r*r:�storager/�pyarrow.compute�computer��	_pa_array�
chunked_array�chunks�combine_chunks�dictionary_encode�	fill_nullr�slicer�r�rKr'�
dictionary�_sort_labels�
null_countr!�putmaskr8r(�numpy_dtype�_values_for_factorizer+�asarray�int64�#_convert_arrays_and_get_rizer_klass�max�	factorizer��_maskr7r0�	get_count�uniques�to_array)r[r\rM�pa�pc�len_lk�dcr�r�r�rN�lmask�lany�rmask�ranyr��klass�rizers                  r]r�r�^	s|��l	�2�8�8�_�-�*�R�X�X��2W�

�/�/�"�(�(�C�
(�S�_�_�R�X�X�s�-K��o�r�*�A�A�"�E���B�
�/�2�
&�
/�
/��
�/�2�
&�
/�
/��	�2�8�8�-�.��r�x�x�!1�2��H�H���� ��"�k�*�*�*��"�k�*�*�*��
*�
*�2�
.��
�"�(�(�
#��
�"�(�(�
#��	�B��	'�B�H�H����,@��r�x�x��,�����1J��r�x�x��-���� � �$@�@� �(���W�F����B����B�� � ����R�Y�Y�!6�7���!�"�"�$�
����R�Z�Z��f�
�6��;���������e��,����R�Z�Z��f�d�(;�<�b�A���������e��,��B�M�M�"��$�D���-�-�0�0��0�F��)�'�4��>�
��d��}�}�q� ���
���y�y�{����
���y�y�{����J�J�t�U�E�2���J�J�t�U�E�2���
����u�$�$��"�o�.��r�x�x��,� ����!5�!5�6�"�2�8�8�,���,�,�.�E�B���,�,�.�E�B���2�8�8�$����R�X�X�)=��Z�Z��"�(�(�
+��
�Z�Z��"�(�(�
+��7��B�?�M�E�2�r��#�c�"�g�s�2�w�'�(�E��"�o�&��"�o�.�.�.����r�x�x�b�h�h��7�����r�x�x�b�h�h��7��	�B�+�	,��"�1�2�2�2�����K�K��"�(�(�*>�*>�K�?�b�g�g�i��
������K�K��"�(�(�*>�*>�K�?�b�g�g�i��
�����r�"�����r�"���:�:����"�'�'�*�*�6�D�J�J�6�*��:�:����"�'�'�*�*�6�D�J�J�6�*��O�O��E���-�-�(�(�*��!�'�4��6�
��d�
�B�J�E��9�9�;�D��B�J�E��9�9�;�D��t���J�J�t�U�E�*���J�J�t�U�E�*�
��
����u��r_c��t|j��r|j|jk7r�t|j|jg�}t|t�r�|j�}t|t�s|j||d��}n|j|d��}t|t�s|j||d��}n:|j|d��}n&|j|d��}|j|d��}t|t�rt|jj}n�t|jt�r(t|jjj}nDt|jj}n&tj}t!|�}t!|�}|||fS)NFrbrS)r(rrrwrrpr9rqr�r8�_factorizersr�r2rE�libhashtable�ObjectFactorizerr )r[r\r�clsrXs     r]rIrI
s^������!�
�8�8�r�x�x��$�b�h�h����%9�:�E��%��0��0�0�2��!�"�n�5��+�+�B�e�%�+�H�B����5�u��5�B�!�"�n�5��+�+�B�e�%�+�H�B����5�u��5�B��Y�Y�u�5�Y�1���Y�Y�u�5�Y�1���b�/�*�!������/�E�
����*�
-� ����!5�!5�!:�!:�;�E� ������/�E��-�-��
�2�
��
�2�
���"�b�=�r_c��t|�}tj||g�}tj||d��\}}|d|||d}}||fS)NT)�use_na_sentinel)r�rKrr#�	safe_sort)	rNrXrY�llengthrr��
new_labels�new_left�	new_rights	         r]rBrBA
sW���$�i�G�
�^�^�T�5�M�
*�F��O�O�G�V�T�J�M�A�z�$�X�g�.�
�7�8�0D�i�H��Y��r_c�>��t�fd�tt��dd�D��}tj�d|d��}||djddd��z}||djddd��z}td|�D]?}tjd	�
�5|�|z}ddd�||||zz
}||||zz
}�A|t��k(r||fSt|||��\}}}	|g||dz}|g||dz}|	f�|dz�t||�|�S#1swY�nxYw)Nc3�>�K�|]}t�d|�s|���y�wrm)r@)rpr^r�s  �r]rrz!_get_join_keys.<locals>.<genexpr>T
s'������+�C�)�%���+�6�	�+�s�rrrbr�r%Frrc)�dividerk)	�nextr�r�rK�prodr�rrr�r�)
r�r�r�rM�nlev�strider�r�r�r�s
  `       r]r�r�M
sO�������U��Q��+���D��W�W�U�1�T�]�$�
/�F��D��G�N�N�4�u�5�N�A�A�D��D��G�N�N�4�u�5�N�A�A�D�
�1�d�^��
�[�[��
)��u�Q�x��F�*���Q��&� � ����Q��&� � ��	��s�5�z���T�z��(��d��>��D�$���6�D���K��D��6�D���K��D�
�H�u�T�U�|�#�E��$��e�T�2�2�*�
)�s�	D�D	c�N�t|t�rt|t�sy||k(S)NT)rwr�)r.r/s  r]r r r
s"���e�S�!��E�3�)?���E�>�r_c�2�|duxrtj|�Srm)r��any_not_none)r�s r]rSrSx
s���D�=�1�S�-�-�q�1�1r_c���t|t�r|St|t�r'|j�t	d��|j�St
dt|��d���)Nz$Cannot merge a Series without a namez.Can only merge Series or DataFrame objects, a z was passed)rwr.r/rr��to_frame�	TypeErrorr�)�objs r]rTrT|
sZ���#�|�$��
�	�C��	#��8�8���C�D�D��|�|�~���<�T�#�Y�K�{�S�
�	
r_c���t|d��rt|t�rtdt	|��d���|j|��t
��dk(r||fS|\}}|s|std�����d�fd�}t||��}t||��}|j|�}|j|�}	g}
|js3||j�|j�zj�}
|	jsB|
j|	|	j�|j�zj��|
rtd	t|
��d
���||	fS)z�
    Suffixes type validation.

    If two indices overlap, add suffixes to overlapping entries.

    If corresponding suffix is empty, the entry is simply converted to string.

    F)�
allow_setszPassing 'suffixes' as a z:, is not supported. Provide 'suffixes' as a tuple instead.rz)columns overlap but no suffix specified: c� ��|�vr|�|�|��S|S)a?
        Rename the left and right indices.

        If there is overlap, and suffix is not None, add
        suffix, otherwise, leave it as-is.

        Parameters
        ----------
        x : original column name
        suffix : str or None

        Returns
        -------
        x : renamed column name
        rd)r��suffix�	to_renames  �r]�renamerz+_items_overlap_with_suffix.<locals>.renamer�
s$��� 
�	�>�f�0��S���>�!��r_)rwz1Passing 'suffixes' which cause duplicate columns z is not allowed.)rwr�)r&rw�dictrrr�r�r�r�r�_transform_indexr��
duplicatedr��extendrr�)rXrYrN�lsuffix�rsuffixry�lrenamer�rrenamerr�r��dupsrxs           @r]r�r��
so�����U�3�z�(�D�7Q��&�t�H�~�&6�75�
5�
�	
�
�!�!�%�(�I�
�9�~����U�{����G�W��7��D�Y�K�P�Q�Q��(�w�w�/�H��w�w�/�H��#�#�H�-�G��$�$�X�.�G�
�D������*�*�,�$�/�/�2C�1C�D�E�L�L�N��������G�W�/�/�1�u�7G�7G�7I�6I�J�K�R�R�T�U���?��D�	�{�K�
�
�	
�
�G��r_)rcNNNFFFr�NFN)rXr�rYr�rRrrHr�rIr�rJr�rKr�rLr�rMr�rNrrQr�rOr�rPr�r�rA)
NNNFFFr�NFN)rXrArYrArHr�rIr�rJr�rKr�rLr�rMr�rNrrQr�rOr�rPr�r�rA)rXr�rYr�)NNNNNNr�r�)rXr�rYr�rHr�rIr�rJr�r�r�rNrrRrr�rA)NNNFFNNNr�NTr�)rXr�rYr�rHr�rIr�rJr�rKr�rLr�rNrr�zint | Timedelta | Noner�r�r�r�r�rA)Frc)
rWr�rXr�rMr�rRrr�r�)
rXrrYrrMr�rRrr�r)rXr5rYr5r�r4r��npt.NDArray[np.intp]r�r�r�z)tuple[FrozenList, FrozenList, FrozenList])r�r�)rr�r�r5rMr�r�rr)rHr�r+r�r�r)F)
rFr4rGr4rr�rMr�r�z?tuple[Index, npt.NDArray[np.intp] | None, npt.NDArray[np.intp]]r�)r[rr\rrMr�r�z6tuple[npt.NDArray[np.intp], npt.NDArray[np.intp], int])r[rr\rr�z:tuple[type[libhashtable.Factorizer], ArrayLike, ArrayLike])rNrrXr�rYr�r�r)
r��%list[npt.NDArray[np.int64 | np.intp]]r�r�r�rrMr�r�z3tuple[npt.NDArray[np.int64], npt.NDArray[np.int64]])r�r�)rsr�r�rA)rXr4rYr4rNrr�ztuple[Index, Index])�r��
__future__r�collections.abcrrr��	functoolsr�typingrrr	r
rert�numpyrK�pandas._libsrrr\r
r�r�pandas._libs.libr�pandas._typingrrrrrrrr�
pandas.errorsr�pandas.util._decoratorsrrr�pandas.util._exceptionsr�pandas.core.dtypes.baser�pandas.core.dtypes.castr�pandas.core.dtypes.commonrr r!r"r#r$r%r&r'r(r)r*r+�pandas.core.dtypes.dtypesr,r-�pandas.core.dtypes.genericr.r/�pandas.core.dtypes.missingr0r1r�r2r3r4r5r6�pandas.core.algorithms�core�
algorithmsr#�pandas.core.arraysr7r8r9�pandas.core.arrays.string_r:�pandas.core.common�commonr��pandas.core.constructionr;r<�pandas.core.framer=�pandas.core.indexes.apir>�pandas.core.sortingr?r@rA�pandas.corerBrC�pandas.core.indexes.frozenrDrH�Int64Factorizer�longlong�int32�Int32Factorizer�int16�Int16Factorizerr��Int8Factorizer�uint64�UInt64Factorizer�uint32�UInt32Factorizer�uint16�UInt16Factorizer�uint8�UInt8Factorizer�bool_�float64�Float64Factorizer�float32�Float32Factorizer�	complex64�Complex64Factorizer�
complex128�Complex128Factorizer�object_r]r[�intc�ndarrayrr^rUr�r�r�rVr>r�r�r�r�r�r#r�r�rDr�rIrBr�r rSrTr�rdr_r]�<module>r�s���#�����������.�	�	�	�%���
5�2�4��������
��'�&���
3� � ��)�1��
� �#�0�5��H�H�l�*�*��K�K��-�-��H�H�l�*�*��H�H�l�*�*��G�G�\�
(�
(��I�I�|�,�,��I�I�|�,�,��I�I�|�,�,��H�H�l�*�*��H�H�l�*�*��J�J��.�.��J�J��.�.��L�L�,�2�2��M�M�<�4�4��J�J��-�-���&�7�7�"�(�(��(�8�8�L�����
�*�*�n�e�Y�	7���2�3�	�*�a� ��+/�04�15����%��!��/(�
�/(��/(�
�/(�	)�	/(�
.�/(�/�
/(��/(��/(��/(��/(��/(��/(��/(��/(�!�4�/(�j,0�04�15����%��!��4�
�4��4�	)�4�.�	4�
/�4��
4��4��4��4��4��4��4��4�n6� �6�);�6�x!�!%�"&��
�"�%��J�
�J��J�	�J��	J�
 �J��J��J�
�J��J�`!�!%�"&�����
�%�(,� $��L�
�L��L�	�L��	L�
 �L��
L��L��L�&�L��L��L��L�bP�P�l��	K��K��K��K�
�	K�
E�K�b��	 �
� �� �� �
�	 �
7� �FV/�
�V/��V/��	V/�
#�V/�#�
V/�/�V/�r9�O�9�x(�
R��R�j
���'1��9=��6��B��
����6��<OT�(�
�(�#�(�0?�(�GK�(�D�(�:04�{��{� �{�(,�{�;�{�|"��"� �"�?�"�J	�
�	�3�	�<P�	�6�	�"3�
/�"3�
/�"3��"3��	"3�
9�"3�J�2�

�A�
�A��A�)1�A��Ar_

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists