Sindbad~EG File Manager

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

�

Mٜg�f���dZddlmZddlmZddlmZmZmZm	Z	m
Z
ddlZddlZ
ddlmZddlmZddlmZdd	lmZmZmZdd
lmZmZmZmZmZddlmZddlm Z dd
l!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-ddl.m/Z/ddl0m1Z1m2Z2m3Z3m4Z4ddl5m6Z6ddl7m8cm9Z:erddl;m<Z<m=Z=ddl>m?Z?		d$							d%d�Z@eAhd��ZBe
	d&							d'd��ZCe
	d&							d(d��ZC	d)							d(d�ZCd�ZDd*d�ZE		d+dd�									d,d�ZFd-d�ZGd.d�ZHdd�									d/d �ZI								d0d!�ZJd1d"�ZK								d2d#�ZLy)3z�
Constructor functions intended to be shared by pd.array, Series.__init__,
and Index.__new__.

These should not depend on core.internals.
�)�annotations)�Sequence)�
TYPE_CHECKING�Optional�Union�cast�overloadN)�ma)�using_pyarrow_string_dtype)�lib)�Period�get_supported_dtype�is_supported_dtype)�AnyArrayLike�	ArrayLike�Dtype�DtypeObj�T)�find_stack_level)�ExtensionDtype)�"construct_1d_arraylike_from_scalar�'construct_1d_object_array_from_listlike�maybe_cast_to_datetime�maybe_cast_to_integer_array�maybe_convert_platform�maybe_infer_to_datetimelike�
maybe_promote)�is_list_like�is_object_dtype�is_string_dtype�pandas_dtype)�NumpyEADtype)�ABCDataFrame�ABCExtensionArray�ABCIndex�	ABCSeries)�isna)�Index�Series)�ExtensionArrayc��ddlm}m}m}m}m}m}m}	m}
m	}ddl
m}tj|�rd|�d�}
t|
��t|t �rt#d��|�#t|t$t&|f�r|j(}t+|d�	�}|�t-|�}t||�r%|�|j(|k(r|r|j/�S|St|t0�r$|j3�}|j5|||�
�S|��wtj6|d��}|dk(r>t9t:t<t>t@tBf|�}|
j5||�
�S|dk(r
|||�
�S|jEd�r	|j5||�
�S|jEd�r|j5||�
�S|dk(r+|�}|j3�}|j5|||�
�S|dk(r|j5||�
�S|dk(r*tG|d�stI|�s|j5||�
�S|dvr1tK|dd�tLjNk7r|j5||�
�S|dk(r|j5|d|�
�StjP|d�rtS|�r|j5|||�
�StjP|d�rtS|�r|j5|||�
�StjP|d�r$tUjVdtXt[���|	j5|||�
�S#t$rY��wxYw)a�
    Create an array.

    Parameters
    ----------
    data : Sequence of objects
        The scalars inside `data` should be instances of the
        scalar type for `dtype`. It's expected that `data`
        represents a 1-dimensional array of data.

        When `data` is an Index or Series, the underlying array
        will be extracted from `data`.

    dtype : str, np.dtype, or ExtensionDtype, optional
        The dtype to use for the array. This may be a NumPy
        dtype or an extension type registered with pandas using
        :meth:`pandas.api.extensions.register_extension_dtype`.

        If not specified, there are two possibilities:

        1. When `data` is a :class:`Series`, :class:`Index`, or
           :class:`ExtensionArray`, the `dtype` will be taken
           from the data.
        2. Otherwise, pandas will attempt to infer the `dtype`
           from the data.

        Note that when `data` is a NumPy array, ``data.dtype`` is
        *not* used for inferring the array type. This is because
        NumPy cannot represent all the types of data that can be
        held in extension arrays.

        Currently, pandas will infer an extension dtype for sequences of

        ============================== =======================================
        Scalar Type                    Array Type
        ============================== =======================================
        :class:`pandas.Interval`       :class:`pandas.arrays.IntervalArray`
        :class:`pandas.Period`         :class:`pandas.arrays.PeriodArray`
        :class:`datetime.datetime`     :class:`pandas.arrays.DatetimeArray`
        :class:`datetime.timedelta`    :class:`pandas.arrays.TimedeltaArray`
        :class:`int`                   :class:`pandas.arrays.IntegerArray`
        :class:`float`                 :class:`pandas.arrays.FloatingArray`
        :class:`str`                   :class:`pandas.arrays.StringArray` or
                                       :class:`pandas.arrays.ArrowStringArray`
        :class:`bool`                  :class:`pandas.arrays.BooleanArray`
        ============================== =======================================

        The ExtensionArray created when the scalar type is :class:`str` is determined by
        ``pd.options.mode.string_storage`` if the dtype is not explicitly given.

        For all other cases, NumPy's usual inference rules will be used.
    copy : bool, default True
        Whether to copy the data, even if not necessary. Depending
        on the type of `data`, creating the new array may require
        copying data, even if ``copy=False``.

    Returns
    -------
    ExtensionArray
        The newly created array.

    Raises
    ------
    ValueError
        When `data` is not 1-dimensional.

    See Also
    --------
    numpy.array : Construct a NumPy array.
    Series : Construct a pandas Series.
    Index : Construct a pandas Index.
    arrays.NumpyExtensionArray : ExtensionArray wrapping a NumPy array.
    Series.array : Extract the array stored within a Series.

    Notes
    -----
    Omitting the `dtype` argument means pandas will attempt to infer the
    best array type from the values in the data. As new array types are
    added by pandas and 3rd party libraries, the "best" array type may
    change. We recommend specifying `dtype` to ensure that

    1. the correct array type for the data is returned
    2. the returned array type doesn't change as new extension types
       are added by pandas and third-party libraries

    Additionally, if the underlying memory representation of the returned
    array matters, we recommend specifying the `dtype` as a concrete object
    rather than a string alias or allowing it to be inferred. For example,
    a future version of pandas or a 3rd-party library may include a
    dedicated ExtensionArray for string data. In this event, the following
    would no longer return a :class:`arrays.NumpyExtensionArray` backed by a
    NumPy array.

    >>> pd.array(['a', 'b'], dtype=str)
    <NumpyExtensionArray>
    ['a', 'b']
    Length: 2, dtype: str32

    This would instead return the new ExtensionArray dedicated for string
    data. If you really need the new array to be backed by a  NumPy array,
    specify that in the dtype.

    >>> pd.array(['a', 'b'], dtype=np.dtype("<U1"))
    <NumpyExtensionArray>
    ['a', 'b']
    Length: 2, dtype: str32

    Finally, Pandas has arrays that mostly overlap with NumPy

      * :class:`arrays.DatetimeArray`
      * :class:`arrays.TimedeltaArray`

    When data with a ``datetime64[ns]`` or ``timedelta64[ns]`` dtype is
    passed, pandas will always return a ``DatetimeArray`` or ``TimedeltaArray``
    rather than a ``NumpyExtensionArray``. This is for symmetry with the case of
    timezone-aware data, which NumPy does not natively support.

    >>> pd.array(['2015', '2016'], dtype='datetime64[ns]')
    <DatetimeArray>
    ['2015-01-01 00:00:00', '2016-01-01 00:00:00']
    Length: 2, dtype: datetime64[ns]

    >>> pd.array(["1h", "2h"], dtype='timedelta64[ns]')
    <TimedeltaArray>
    ['0 days 01:00:00', '0 days 02:00:00']
    Length: 2, dtype: timedelta64[ns]

    Examples
    --------
    If a dtype is not specified, pandas will infer the best dtype from the values.
    See the description of `dtype` for the types pandas infers for.

    >>> pd.array([1, 2])
    <IntegerArray>
    [1, 2]
    Length: 2, dtype: Int64

    >>> pd.array([1, 2, np.nan])
    <IntegerArray>
    [1, 2, <NA>]
    Length: 3, dtype: Int64

    >>> pd.array([1.1, 2.2])
    <FloatingArray>
    [1.1, 2.2]
    Length: 2, dtype: Float64

    >>> pd.array(["a", None, "c"])
    <StringArray>
    ['a', <NA>, 'c']
    Length: 3, dtype: string

    >>> with pd.option_context("string_storage", "pyarrow"):
    ...     arr = pd.array(["a", None, "c"])
    ...
    >>> arr
    <ArrowStringArray>
    ['a', <NA>, 'c']
    Length: 3, dtype: string

    >>> pd.array([pd.Period('2000', freq="D"), pd.Period("2000", freq="D")])
    <PeriodArray>
    ['2000-01-01', '2000-01-01']
    Length: 2, dtype: period[D]

    You can use the string alias for `dtype`

    >>> pd.array(['a', 'b', 'a'], dtype='category')
    ['a', 'b', 'a']
    Categories (2, object): ['a', 'b']

    Or specify the actual dtype

    >>> pd.array(['a', 'b', 'a'],
    ...          dtype=pd.CategoricalDtype(['a', 'b', 'c'], ordered=True))
    ['a', 'b', 'a']
    Categories (3, object): ['a' < 'b' < 'c']

    If pandas does not infer a dedicated extension type a
    :class:`arrays.NumpyExtensionArray` is returned.

    >>> pd.array([1 + 1j, 3 + 2j])
    <NumpyExtensionArray>
    [(1+1j), (3+2j)]
    Length: 2, dtype: complex128

    As mentioned in the "Notes" section, new extension types may be added
    in the future (by pandas or 3rd party libraries), causing the return
    value to no longer be a :class:`arrays.NumpyExtensionArray`. Specify the
    `dtype` as a NumPy dtype if you need to ensure there's no future change in
    behavior.

    >>> pd.array([1, 2], dtype=np.dtype("int32"))
    <NumpyExtensionArray>
    [1, 2]
    Length: 2, dtype: int32

    `data` must be 1-dimensional. A ValueError is raised when the input
    has the wrong dimensionality.

    >>> pd.array(1)
    Traceback (most recent call last):
      ...
    ValueError: Cannot pass scalar '1' to 'pandas.array'.
    r)	�BooleanArray�
DatetimeArrayr*�
FloatingArray�IntegerArray�
IntervalArray�NumpyExtensionArray�PeriodArray�TimedeltaArray��StringDtypezCannot pass scalar 'z' to 'pandas.array'.z'Cannot pass DataFrame to 'pandas.array'NT)�
extract_numpy��dtype�copy)�skipna�period�r9�interval�datetime�	timedelta�string�integer�emptyr8)�floatingzmixed-integer-float�boolean�M�m�mMz�datetime64 and timedelta64 dtype resolutions other than 's', 'ms', 'us', and 'ns' are deprecated. In future releases passing unsupported resolutions will raise an exception.)�
stacklevel).�pandas.core.arraysr,r-r*r.r/r0r1r2r3�pandas.core.arrays.string_r5r�	is_scalar�
ValueError�
isinstancer#�	TypeErrorr&r%r8�
extract_arrayr!r9r�construct_array_type�_from_sequence�infer_dtyperrrrr
r�
startswith�hasattr�len�getattr�np�float16�is_np_dtyper�warnings�warn�
FutureWarningr)�datar8r9r,r-r*r.r/r0r1r2r3r5�msg�cls�inferred_dtype�period_datas                 �C/usr/local/lib/python3.12/site-packages/pandas/core/construction.py�arrayrcJs1��d
�
�
�7�
�}�}�T��$�T�F�*>�?����o��	�D�,�	'��A�B�B��}��D�9�h��*O�P��
�
����T�2�D�
���U�#���$��'�U�]�d�j�j�E�>Q���9�9�;�����%��(��(�(�*���!�!�$�e�$�!�?�?��}�����d�;���X�%��u�X�h�v�.>�%?��%M�N�PT�U�K��-�-�k��-�E�E�
�z�
)� ��D�1�1�
�
&�
&�z�
2�
�$�3�3�D�t�3�D�D�
�
&�
&�{�
3�!�0�0��D�0�A�A�
�x�
'��M�E��,�,�.�C��%�%�d�%�d�%�C�C�
�y�
(��.�.�t�$�.�?�?�
�w�
&�w�t�W�/E�c�RV�i� �/�/��4�/�@�@��A�A���g�t�,��
�
�:�!�/�/��4�/�@�@�
�y�
(��.�.�t�9�4�.�P�P����u�c�"�'9�%�'@��+�+�D��D�+�I�I�
���u�c�"�'9�%�'@��,�,�T��T�,�J�J�	�����	%��
�
�
#�
�'�)�
	
��-�-�d�%�d�-�K�K��a�
��
�s�L4�4	M�?M>	�index�series�
multiindex�
rangeindex�periodindex�
datetimeindex�
intervalindex�timedeltaindex�categoricalindexc��y�N���objr6�
extract_ranges   rbrOrO�����c��yrnrorps   rbrOrO�rsrtFc��t|dd�}|tvr!|dk(r|r|jS|S|jS|r|dk(r|j�S|S)a�
    Extract the ndarray or ExtensionArray from a Series or Index.

    For all other types, `obj` is just returned as is.

    Parameters
    ----------
    obj : object
        For Series / Index, the underlying ExtensionArray is unboxed.

    extract_numpy : bool, default False
        Whether to extract the ndarray from a NumpyExtensionArray.

    extract_range : bool, default False
        If we have a RangeIndex, return range._values if True
        (which is a materialized integer ndarray), otherwise return unchanged.

    Returns
    -------
    arr : object

    Examples
    --------
    >>> extract_array(pd.Series(['a', 'b', 'c'], dtype='category'))
    ['a', 'b', 'c']
    Categories (3, object): ['a', 'b', 'c']

    Other objects like lists, arrays, and DataFrames are just passed through.

    >>> extract_array([1, 2, 3])
    [1, 2, 3]

    For an ndarray-backed Series / Index the ndarray is returned.

    >>> extract_array(pd.Series([1, 2, 3]))
    array([1, 2, 3])

    To extract all the way down to the ndarray, pass ``extract_numpy=True``.

    >>> extract_array(pd.Series([1, 2, 3]), extract_numpy=True)
    array([1, 2, 3])
    �_typNrg�
npy_extension)rV�_typs�_values�to_numpy)rqr6rr�typs    rbrOrO�s]��Z�#�v�t�
$�C�
�e�|��,����{�{�"��J��{�{��	�3�/�1��|�|�~���Jrtc�V�t|tj�r�|jjdk(r.ddlm}t|j�}|j||��S|jjdk(r.ddlm	}t|j�}|j||��S|S)zS
    Wrap datetime64 and timedelta64 ndarrays in DatetimeArray/TimedeltaArray.
    rEr)r-�r8rF)r3)
rMrW�ndarrayr8�kindrIr-rrQr3)�arrr-r8r3s    rb�ensure_wrapped_if_datetimeliker��s����#�r�z�z�"��9�9�>�>�S� �8�'��	�	�2�E� �/�/��5�/�A�A�
�Y�Y�^�^�s�
"�9�'��	�	�2�E�!�0�0��E�0�B�B��Jrtc�l�tj|�}|j�r~t|jt
j�\}}tt
j|�}tj|j|d���}|j�|||<|S|j�}|S)z?
    Convert numpy MaskedArray to ensure mask is softened.
    Tr<)r
�getmaskarray�anyrr8rW�nanr�asarray�astype�soften_maskr9)r]�maskr8�
fill_values    rb�sanitize_masked_arrayr��s����?�?�4� �D��x�x�z�)�$�*�*�b�f�f�=���z��R�X�X�u�%���z�z�$�+�+�e�$�+�7�8��������T�
��K��y�y�{���Krt��allow_2dc���|}t|tj�rt|�}t|t�r|j
}d}t|t�r|jtk(r|�d}t|dd��}t|tj�r3|jdk(r$|�|j}tj|�}nt|t�r
t!|�}d}t#|�sO|�t%d��t|t&�rt)�r|�ddlm}|d�}t/|t1|�|�}|St|t2�r/|�|j5||��}�n9|r|j7�}�n%|}�n!t|t8�r1t;|�|j=�}	|	j?|||�	�}�n�t|tj�r�t|tj@�r|jB}|��|}|jtk(r%tE|�}|rkt)�ratG|�rV|}nS|jjHd
k(r:t)�r0ddlm}|d��}|j=�j?||��}||u�r|�r	|j7�}n�tK|||�}n�tM|d
�r?|stjN|�}ntjP||��}tS|||d|��St;|�tU|�}t1|�dk(r(|�&tjPgtjV��}nS|�tK|||�}nCtY|�}|jtk(r%t[tj|�}tE|�}t]|||||��}t|tj�r(t[tj|�}t_||||�}|S)a�
    Sanitize input data to an ndarray or ExtensionArray, copy if specified,
    coerce to the dtype if specified.

    Parameters
    ----------
    data : Any
    index : Index or None, default None
    dtype : np.dtype, ExtensionDtype, or None, default None
    copy : bool, default False
    allow_2d : bool, default False
        If False, raise if we have a 2D Arraylike.

    Returns
    -------
    np.ndarray or ExtensionArray
    FT)r6rrrz2index must be specified when data is not list-liker4�
pyarrow_numpyr<r7�U)�storager~�	__array__)rdr8r9r�r�)0rMr
�MaskedArrayr�r"�numpy_dtyper%r8�objectrOrWr�ndimr�item_from_zerodim�range�range_to_ndarrayrrL�strrrJr5rrUr$r�r9r�_sanitize_non_orderedrPrQ�matrix�Arr r��	_try_castrTr�rc�sanitize_array�list�float64rr�_sanitize_ndim�_sanitize_str_dtypes)
r]rdr8r9r��original_dtype�object_indexr5�subarrr_s
          rbr�r�sG��2�N��$����'�$�T�*���%��&��!�!���L��$��!�d�j�j�F�&:�u�}�����T��F�D��$��
�
�#��	�	�Q���=��J�J�E��$�$�T�*��	�D�%�	 ���%��������=��Q�R�R��t�S�!�*�,��&�>���0�E�1�$��E�
�E�J����	�D�+�	,����[�[��T�[�2�F�
��Y�Y�[�F��F�	�E�>�	*��d�#��(�(�*���#�#�D��D�#�A��
�D�"�*�*�	%��d�B�I�I�&��6�6�D��=��F��z�z�V�#�4�T�:�� �2�4�'��/�"�F������C�'�,F�,H�B�#�O�<���3�3�5�D�D�T�QV�D�W����~�$�������t�U�D�1�F�	��{�	#���:�:�d�#�D��8�8�D�t�,�D�������
�	
�	�d�#��D�z���t�9��>�e�m��X�X�b��
�
�3�F�
�
��t�U�D�1�F�,�D�1�F��|�|�v�%��b�j�j�&�1��4�V�<��
�F�D�%���
J�F��&�"�*�*�%��R�X�X�u�%��%�f�d�E�4�@���Mrtc��	tj|j|j|jd��}|S#t
$r�|jdk\r|jdkDs"|jdcxkr|jkrcnn`	tj|j|j|jd��}Y|S#t
$rt
t|��}YY|SwxYwt
t|��}Y|SwxYw)z)
    Cast a range object to ndarray.
    �int64r~r�uint64)rW�arange�start�stop�step�
OverflowErrorrr�)�rngr�s  rbr�r��s���

E��i�i��	�	�3�8�8�S�X�X�W�E���J���E��I�I��N�s�x�x�!�|����A�1I����1I�
I��i�i��	�	�3�8�8�S�X�X�X�N��
�J��	!�
I�=�d�3�i�H���J�	
I��:�$�s�)�D�C��J�E�s.�7;�A	C<�7B?�?C!�C<� C!�!C<�;C<c�t�t|ttf�r"tdt	|�j
�d���y)z@
    Raise only for unordered sets, e.g., not for dict_keys
    �'z' type is unorderedN)rM�set�	frozensetrN�type�__name__)r]s rbr�r��s8���$��i�(�)��!�D��J�/�/�0�0C�D�E�E�*rtc��t|dd�dk(rtd��|jdk(rt||�}|S|jdkDr�t	|t
j�r|r|Std|j�d���t|�r_t	|t�rOtj|tjd���}|j�}|j||��}|Stj||��}|S)	z6
    Ensure we have a 1-dimensional result array.
    r�rz(result should be arraylike with ndim > 0�z1Data must be 1-dimensional, got ndarray of shape z insteadr�r~)rVrLr��
_maybe_repeatrMrWr�shaperr�com�asarray_tuplesafer8rPrQ)�resultr]r8rdr�r_s      rbr�r��s����v�v�q�!�Q�&��C�D�D�
�{�{�a���v�u�-��(�M�%
���q���d�B�J�J�'���
��C�D�J�J�<�x�X��
��5�!�j���&G��*�*�4�r�x�x��7I�J�F��,�,�.�C��'�'��e�'�<�F��M��*�*�4�u�=�F��Mrtc�X�t|jjt�r�t	j
|�spt
jt|��st
j||��}|st
j|t��}|St
j|t|��}|S)z=
    Ensure we have a dtype that is supported by pandas.
    r~r7)�
issubclassr8r�r�rrKrW�allr'r�r�rc)r�r]r8r9s    rbr�r��sy���&�,�,�#�#�S�)��}�}�T�"��6�6�$�t�*�%��z�z�$�e�4������D��7���M����$�f�4�@���Mrtc��|�;dt|�cxk(rt|�k7rn|S|jt|��}|S)zx
    If we have a length-1 array and an index describing how long we expect
    the result to be, repeat the array.
    r�)rU�repeat)r�rds  rbr�r��s=��

����C��&�C��J�&��J��*�*�S��Z�(�C��Jrtc��t|tj�}|tk(r+|s
t	|�}|St|�j
||��S|jdk(r{|rFttj|�}|j}|jdkDr|j�}nt|�f}tj|d|��j|�S|jdvrt!||�S|jdvrt#||�}|S|stj$||��}|Stj&|||�	�}|S)
aL
    Convert input to numpy ndarray and optionally cast to a given dtype.

    Parameters
    ----------
    arr : ndarray or list
        Excludes: ExtensionArray, Series, Index.
    dtype : np.dtype
    copy : bool
        If False, don't copy the data if not needed.

    Returns
    -------
    np.ndarray or ExtensionArray
    r<r�r�F)�convert_na_valuer9rG�iur~r7)rMrWrr�rr�r�r�rr�r��ravelrUr�ensure_string_array�reshaperrr�rc)r�r8r9�
is_ndarrayr�r�s      rbr�r�s)��(�C����,�J�����<�S�A�F��M�-�c�2�9�9�%�d�9�K�K�	���s�	���r�z�z�3�'�C��I�I�E��x�x�!�|��i�i�k����X�K�E��&�&�s�U��N�V�V��
�	
�
���t�	�%�c�5�1�1�
���t�	�-�S�%�8���M�����C�u�-���M����#�U��6���Mrt)NT)r]zSequence[object] | AnyArrayLiker8zDtype | Noner9�bool�returnr*)..)rqzSeries | Indexr6r�rrr�r�r)rqrr6r�rrr�r�z
T | ArrayLike)FF)r]zma.MaskedArrayr��
np.ndarray)NF)
rd�Index | Noner8�DtypeObj | Noner9r�r�r�r�r)r�r�r�r�)r��None)
r�rr8r�rdr�r�r�r�r)r�r�r8znp.dtype | Noner9r�r�r�)r�rrdr�r�r)r�zlist | np.ndarrayr8znp.dtyper9r�r�r)M�__doc__�
__future__r�collections.abcr�typingrrrrr	rZ�numpyrWr
�pandas._configr�pandas._libsr�pandas._libs.tslibsr
rr�pandas._typingrrrrr�pandas.util._exceptionsr�pandas.core.dtypes.baser�pandas.core.dtypes.castrrrrrrr�pandas.core.dtypes.commonrrr r!�pandas.core.dtypes.dtypesr"�pandas.core.dtypes.genericr#r$r%r&�pandas.core.dtypes.missingr'�pandas.core.common�core�commonr��pandasr(r)�pandas.core.arrays.baser*rcr�ryrOr�r�r�r�r�r�r�r�r�rortrb�<module>r�sc���#�$������5����
��5�2������3���,� � ���7�
��vL�
)�vL��vL��vL��	vL�r		�
�	��
�JM��	��(,��CG����
��
�=@��	
����6:����
��@E�>�	
�>��>�8<�>��>�B�(
�&"��	U��
U��U��U��	U��
U��U�p�&F��
$��$��$��	$��
$��$�N���%4��<@����.�7�	�7��7��7��	7rt

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