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__/generic.cpython-312.pyc

�

Mٜg=���UddlmZddlZddlmZddlZddlmZddl	Z	ddl
mZddlZddl
Z
ddlZddlZddlmZmZmZmZmZmZmZmZmZddlZddlZddlZddlmZm Z m!Z!ddl"m#Z#dd	l$m%Z%dd
l&m'Z'm(Z(m)Z)m*Z*ddl+m,Z,ddl-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZdd
l[m\Z\ddl]m^Z^ddl_m`Z`ddlambZcddldmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlddlmmnZnmoZoddlpmqZqddlrmsZsmtZtmuZumvZvmwZwddlxmyZyddlzm{Z{m|Z|m}Z}m~Z~mZm�Z�m�Z�m�Z�m�Z�m�Z�m�Z�m�Z�m�Z�ddl�m�Z�m�Z�ddl�m�Z�m�Z�ddl�m�Z�m�Z�ddl�m�Z�m�Z�ddl�m�Z�m�Z�m�Z�m�Z�m�Z�m�Z�m�Z�ddl�m�Z�ddl�m�Z�ddl�m�Z�ddl�m�Z�dd l�m�Z�dd!l�m�Z�m�Z�m�Z�m�Z�m�Z�m�Z�m�Z�dd"l�m�Z�m�Z�m�Z�dd#l�m�Z�m�Z�dd$l�m�Z�dd%l�m�Z�m�Z�m�Z�dd&l�m�Z�dd'l�m�Z�dd(l�m�Z�dd)l�m�Z�m�Z�m�Z�m�Z�dd*l�m�Z�m�Z�dd+l�m�Z�er*dd,l�m�Z�m�Z�m�Z�m�Z�dd-l&m�Z�dd.l�m�Z�m�Z�m�Z�m�Z�dd/l�m�Z�dd0l�m�Z�ie��Z�d1d2d3d4d5d6�Z�e�Z�Gd7�d8e�e��j��Z�d9Z�d:Z�d;Z�d<Z�d=Z�d>Z�d?Z�d@Z�dAZ�dBZ�dCZ�dDZ�dEZ�dFZ�dGZ�dHZ�dIZ�dJZ�dKe�dL<e�dL�j�dMdNdOdPdQ�R�Z�e�dSz
Z�e�dL�j�dTdUdQdVdQ�R�Z�dWe�dX<e�dL�j�dYdZdd[d�R�Z�dWe�d\<d]Z�d^Z�d_Z�dad`�Z�y)b�)�annotationsN)�deepcopy)�partial)�loads)	�
TYPE_CHECKING�Any�Callable�ClassVar�Literal�NoReturn�cast�final�overload)�config�using_copy_on_write�warn_copy_on_write)�lib)�is_range_indexer)�Period�Tick�	Timestamp�	to_offset)�freq_to_period_freqstr)-�	AlignJoin�AnyArrayLike�	ArrayLike�Axes�Axis�AxisInt�CompressionOptions�DtypeArg�DtypeBackend�DtypeObj�FilePath�
FillnaOptions�FloatFormatType�FormattersType�	Frequency�IgnoreRaise�IndexKeyFunc�
IndexLabel�InterpolateOptions�IntervalClosedType�JSONSerializable�Level�Manager�
NaPosition�NDFrameT�OpenFileErrors�RandomState�
ReindexMethod�Renamer�Scalar�Self�SequenceNotStr�SortKind�StorageOptions�Suffixes�T�
TimeAmbiguous�TimedeltaConvertibleTypes�TimeNonexistent�TimestampConvertibleTypes�TimeUnit�ValueKeyFunc�WriteBuffer�WriteExcelBuffer�npt)�PYPY)�	REF_COUNT)�import_optional_dependency)�function)�AbstractMethodError�ChainedAssignmentError�InvalidIndexError�SettingWithCopyError�SettingWithCopyWarning�_chained_assignment_method_msg�&_chained_assignment_warning_method_msg�
_check_cacher)�deprecate_nonkeyword_arguments�doc)�find_stack_level)�check_dtype_backend�validate_ascending�validate_bool_kwarg�validate_fillna_kwargs�validate_inclusive)�astype_is_view)
�
ensure_object�ensure_platform_int�
ensure_str�is_bool�
is_bool_dtype�is_dict_like�is_extension_array_dtype�is_list_like�	is_number�is_numeric_dtype�is_re_compilable�	is_scalar�pandas_dtype)�DatetimeTZDtype�ExtensionDtype)�ABCDataFrame�	ABCSeries)�is_hashable�is_nested_list_like)�isna�notna)�
algorithms�	arraylike�common�indexing�missing�nanops�sample)�should_use_regex)�ExtensionArray)�PandasObject)�
extract_array)�Flags)�
DatetimeIndex�Index�
MultiIndex�PeriodIndex�
RangeIndex�
default_index�ensure_index)�ArrayManager�BlockManager�SingleArrayManager)�
mgr_to_mgr�ndarray_to_mgr)�describe_ndframe)�clean_fill_method�clean_reindex_fill_method�find_valid_index)�concat)�_shared_docs)�get_indexer_indexer)�	Expanding�ExponentialMovingWindow�Rolling�Window)�DataFrameFormatter�DataFrameRenderer)�pprint_thing)�Hashable�Iterator�Mapping�Sequence)�
BaseOffset)�	DataFrame�ExcelWriter�HDFStore�Series)�BaseIndexer)�	Resamplerzkeywords for axeszSeries/DataFramezG{0 or 'index'} for Series, {0 or 'index', 1 or 'columns'} for DataFramez`
    inplace : bool, default False
        If True, performs operation inplace and returns None.zM
        by : str or list of str
            Name or list of names to sort by)�axes�klass�axes_single_arg�inplace�optional_byc�d.��eZdZUdZgd�Zded<ee�Zded<e�Zded<e	g�Z
ded	<gZded
<dZded
<ded<ded<ded<�ded�Z
ee		�df									�dgd���Ze�dh�did��Zee�djd���Ze�dkd��Zej*�dld��Zee�dmd���Zeddd�					�dnd��Zee�dod���Ze�dpd ��Zeed!���Zd"ed#<d$d$d$d%�Zd&ed'<d(ed)<d*ed+<d(ed,<e�dq�drd-��Zee�dsd.���Zee�dtd/���Ze�dud0��Zee�dsd1���Z e�dvd2��Z!e�dwd3��Z"e�dxd4��Z#ee�dyd5���Z$d6�Z%e�dzd7��Z&e�d{d8��Z'ee�d|d9���Z(ee�d|d:���Z)d$dd;�					�d}d<�Z*e						�d~d>��Z+e�dd?��Z,e�dq�d�d@��Z-ee.e/dA�B��d��d�dC���Z0�d�dD�Z1e�dq�d�dE��Z2e	�dqdddddddFdG�																	�d�dH��Z3e4	�d�dIdIdIdIdIdJ�									�d�dK��Z5e4	�d�dIdIdIdIdL�									�d�dM��Z5e4	�d�dIdIdIdIdIdJ�									�d�dN��Z5e6jnfe6jne6jnd$dddJ�									�d�dO�Z5e	�d�					�d~dP��Z8e�d�dQ��Z9e�d�dS��Z:e�d�dT��Z;e�d�dU��Z<e�d�dV��Z=e�d�dW��Z>e>Z?e�d�dX��Z@e�d�dY��ZAe�d�dZ��ZBe�d��d�d[��ZCe�d��d�d\��ZDe�d��d�d]��ZEe�d��d�d^��ZFe�d��d�d_��ZGe�d��d�d`��ZHe�d��d�da��ZIdbedc<�d�dd�ZJ�dyde�ZKdf�ZL�d|dg�ZMe�d�dh��ZNe�d�di��ZOdjZPd(edk<	�d�					�d�dl�ZQe								�d�dm��ZRe�d�dn��ZSe�d�do��ZT�d�dp�ZUedq��ZVedr��ZWeeXdsdtdugdv�w�e.dReYdxdy�z�															�d�																																	�d�d|����ZZeeXdsdtd}gd~�w�e.eYdxeYdd}z���													�d�																											�d�d�����Z[eeXdsdtd}gd��w�												�d�																											�d�d����Z\eeXdsgd��d��w�							�d�																	�d�d����Z]eeXdsdtd�gd��w�e.eYdxeYdd�z���d�e^j�df									�d�d�����Z`eeXdsdtgd��w�	�d�					�d�d����Zaed���Zbe4																					�d�																																											�d�d���Zce4																				�d�																																											�d�d���ZceeXdsdtd�gd��w�																					�d�																																											�d�d����Zce	�dqdddddd��									�d�d���Zde4																					�d�																																											�d�d���Zee4																				�d�																																											�d�d���ZeeeXdsdtd}gd��w�e.eYdxeYdd}z���																					�d�																																											�d�d�����Ze�d�d��Zf			�d�							�d�d��Zg�d�d��Zhe�d��d�d���Zie�d��d�d���Zje			�d�									�d�d���Zkd��Zle�d�d���Zm�d��d�d��Zne�dh�d�d���Zo�d�d��Zpe�d��d�d���Zqe�d�d���Zre�d�d���Zse�dqd���Ztee�d�d����Zue				�d�							�d�d���Zve4	�d�dIdIdIdIdId��															�d�d���Zwe4	�d�dIdIdIdIdIdId��															�d�d���Zwe4	�d�dIdIdIdIdIdId��															�d�d���Zw	�dqd$ddddd�d��															�d�d��Zwe			�d�					�d�d���Zxe�dh�d�d���Zye�dq�d�d���Zze�dq�d�d���Z{e4dIdIdIdIdIdIdId��															�d�d���Z|e4dIdIdIdIdIdId��															�d�d���Z|e4dIdIdIdIdIdIdId��															�d�d���Z|d$ddd�d�ddd��															�d�d��Z|e4dIdIdIdIdIdIdIdId��																			�d�d���Z}e4dIdIdIdIdIdIdIdIdId��																				�d�d���Z}e4dIdIdIdIdIdIdIdIdId��																				�d�d���Z}d$dddd�d�dddd��																				�d�d„Z}e.e/dAd{�ë	�dqdddddde~j�dddĜ														�d�dń�Z�e										�d�dƄ�Z��d�dDŽZ�dȄZ�e			�d�					�d�dɄ�Z�				�d�							�d�dʄZ�e�d֐d�d˄�Z�e�d֐d�d̄�Z�e							�d�													�d�d΄�Z�ee.e/dA�B�				�d�dτ��Z�e�dq�d�dЄ�Z�e�d�dф�Z�e�d�d҄�Z�e�dވfdӄ�Z�edԄ�Z�e�d�dՄ�Z�edք�Z�ee�d�dׄ��Z�e�d�d؄�Z�edل�Z�edڄ�Z�e�d�dۄ�Z�ed܄�Z�e	�d�					�d�d݄�Z�e�dh�d�dބ�Z�e�dh�d�d߄�Z�e�dq�d�d��Z�e�dq�d�d��Z�e						�d�													�d�d��Z��d�d�Z�edddddd�											�d�d��Z�e4	�d�dIdIdIdIdId�													�d�d��Z�e4	�d�dIdIdIdId�													�d�d��Z�e4	�d�dIdIdIdIdId�													�d�d��Z�ee.e/dAe/d���	�dqdddde6jnd�													�d�d���Z�e4dIdIdIdIdId�											�d�d��Z�e4dIdIdIdId�											�d�d��Z�e4dIdIdIdIdId�											�d�d��Z�ee.e/dAe/d���dddde6jnd�											�d�d���Z�ee.e/dA�B�ddde6jnd�									�d�d���Z�e4dIdIdIdIdId�											�d�d���Z�e4dIdIdId��									�d�d���Z�e4dIdIdIdIdId�											�d�d���Z�ee.e/dAe/d���dddde6jnd�											�d�d����Z�ee.e/dA�B�ddde6jnd�									�d�d����Z�e4		�d�dIdIdIdId��									�d�d���Z�e4		�d�dIdIdId��									�d�d���Z�e4		�d�dIdIdIdId��									�d�d���Z�ee.eYd�e/dAe/d=���de6jnfddde6jnd��									�d��d���Z�e4	�d�dIdIdIdIdIdI�d�															�d��d��Z�e4	�d�dIdIdIdIdI�d�															�d��d��Z�e4	�d�dIdIdIdIdIdI�d�															�d��d��Z�e	�d�d$dddde6jn�d�															�d��d��Z�e�dq�d��Z�e.e/dA�B��d��d	��Z�e.e�e/dA�B��d��d
��Z�e.e/dA�B��d��d��Z�e.e�e/dA�B��d��d��Z�e�d��d��d
��Z�e�d��Z�e4		�d�dIdI�d�					�d��d��Z�e4		�d�dI�d�					�d��d��Z�e4		�d�dIdI�d�					�d��d��Z�e		�d�dd�d�					�d��d��Z�ee.e/dA�B�				�d�											�d��d���Z�e�d�d�d��Z�e		�d					�d�d��Z�ee.e/dA�B�e6jndde6jne6jndd�dddf
																					�d�d���Z�e�d��d��Z�e�d��d��Z�e						�d													�d�d��Z�e.eY�de/dA�B�				�d							�d�d��Z�ee.e/dAe/d����d dddde6jne6jne6jne6jnf																						�d	�d!���Z�e								�d
													�d�d"��Z�e								�d
													�d�d#��Z�ee6jnddddf					�d
�d$��Z�e4	�d�dIdIdI�d%�							�d�d&��Z�e4	�d�dIdI�d'�							�d�d(��Z�e4	�d�dIdIdI�d%�							�d�d)��Z�ee.e/dA�d*�d+�d,�d-��.�e~j�fddd�d%�							�d�d/���Z�e4	�d�dIdIdI�d%�							�d�d0��Z�e4	�d�dIdI�d'�							�d�d1��Z�e4	�d�dIdIdI�d%�							�d�d2��Z�ee.e�e/dA�d+�d*�d-�d,��.�e6jnfddd�d%�							�d�d3���Z�e.e/dA�B��ddd$e6jndf									�d�d4��Z�e�d�d5��Z�e				�d�					�d�d6��Z�ee.e/dA�B�	�d					�d}�d7���Z�ee.e/dA�B�					�d									�d�d8���Z�e			�d	�d��d9��Z�e�de6jne6jndf							�d�d:��Z�e			�d�									�d�d;��Z�			�d�							�d�d<�Z�			�d�							�d�d=�Z�e		�d					�d�d>��ZƐd�d�d?�Zǐd�d�d@�ZȐd�d�dA�Zɐd�d�dB�Z�ee6jnd�ddf											�d �dC��Z�				�d!									�d"�dD�Z�				�d!									�d"�dE�Z�				�d!									�d"�dF�Z�e			�d#							�d$�dG��Z�			�d#					�d%�dH�Z�			�d#					�d%�dI�Z�			�d#							�d&�dJ�Z�			�d#							�d&�dK�Z�			�d#							�d&�dL�Z�			�d#							�d&�dM�Z�e�Z�ee6jnddd$f									�d'�dN��Z�				�d(							�d)�dO�Z�				�d(							�d)�dP�Z�e�Z�ee.e۫dddde6jndd�dQf																			�d*�dR���Z�ee.eݫ�de6jn�dQf							�d+�dS���Z�ee.e߫ddddd$dde6jnd�dQf
																					�d,�dT���Z�e�d��dU��Z�e�d��dV��Z�e�d��dW��Z�e�d��dX��Z�e�d��dY��Z�e�d��dZ��Z�e�d��d[��Z�e�d��d\��Z�e�d��d]��Z�e�d��d^��Z�e�d��d_��Z�e�d-�d`��Z�ee.�dae/dA��b��d.�dc���Z�ee.e�d�e/dA��b��d.�dd���Z�xZ�S(/�NDFramez�
    N-dimensional analogue of DataFrame. Store multi-dimensional in a
    size-mutable, labeled data structure

    Parameters
    ----------
    data : BlockManager
    axes : list
    copy : bool, default False
    )�_mgr�_cacher�_item_cache�_cache�_is_copy�_name�	_metadata�_flagsz	list[str]�_internal_names�set[str]�_internal_names_set�
_accessorszfrozenset[str]�
_hidden_attrsr�Nz+weakref.ReferenceType[NDFrame] | str | Noner�r0r��dict[Hashable, Any]�_attrs�str�_typc��tj|dd�tj|d|�tj|di�tj|di�tj|dt|d���y)Nr�r�r�r�r�T)�allows_duplicate_labels)�object�__setattr__r|��self�datas  �>/usr/local/lib/python3.12/site-packages/pandas/core/generic.py�__init__zNDFrame.__init__sc�����4��T�2����4���.����4���3����4��2�.����4��5��t�+T�U�Fc��|j�D]7\}}|��	t|�}|j|�}|j||��}�9|r|j	�}|�ct|t�rAt|j�dk(r)|jdjj|k(r	|S|j|��}|S)z passed a manager and a axes dict��axis�r��dtype)�itemsr��_get_block_manager_axis�reindex_axis�copy�
isinstancer��len�blocks�valuesr��astype)�cls�mgrr�r�r��a�axe�bm_axiss        r��	_init_mgrzNDFrame._init_mgrs����j�j�l�F�A�s���"�3�'���5�5�a�8���&�&�s��&�9��	#���(�(�*�C����3��-���
�
�O�q�(��J�J�q�M�(�(�.�.�%�7���
��j�j�u�j�-���
r�Tc��t|j||��}|j||j��j	|�S)a�
        Private helper function to create a DataFrame with specific manager.

        Parameters
        ----------
        typ : {"block", "array"}
        copy : bool, default True
            Only controls whether the conversion from Block->ArrayManager
            copies the 1D arrays (to ensure proper/contiguous memory layout).

        Returns
        -------
        DataFrame
            New DataFrame using specified manager type. Is not guaranteed
            to be a copy or not.
        )�typr��r�)r�r��_constructor_from_mgrr��__finalize__)r�r�r��new_mgrs    r��_as_managerzNDFrame._as_manager<s<��&�T�Y�Y�C�d�;���)�)�'����)�E�R�R�SW�X�Xr�c�T�|j|�}tj||�|S)a�
        Construct a new object of this type from a Manager object and axes.

        Parameters
        ----------
        mgr : Manager
            Must have the same ndim as cls.
        axes : list[Index]

        Notes
        -----
        The axes must match mgr.axes, but are required for future-proofing
        in the event that axes are refactored out of the Manager objects.
        )�__new__r�r�)r�r�r��objs    r��	_from_mgrzNDFrame._from_mgrSs'��"�k�k�#�������c�"��
r�c��|jS)a�
        Dictionary of global attributes of this dataset.

        .. warning::

           attrs is experimental and may change without warning.

        See Also
        --------
        DataFrame.flags : Global flags applying to this object.

        Notes
        -----
        Many operations that create new datasets will copy ``attrs``. Copies
        are always deep so that changing ``attrs`` will only affect the
        present dataset. ``pandas.concat`` copies ``attrs`` only if all input
        datasets have the same ``attrs``.

        Examples
        --------
        For Series:

        >>> ser = pd.Series([1, 2, 3])
        >>> ser.attrs = {"A": [10, 20, 30]}
        >>> ser.attrs
        {'A': [10, 20, 30]}

        For DataFrame:

        >>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
        >>> df.attrs = {"A": [10, 20, 30]}
        >>> df.attrs
        {'A': [10, 20, 30]}
        )r��r�s r��attrsz
NDFrame.attrsks��H�{�{�r�c�$�t|�|_y�N)�dictr�)r��values  r�r�z
NDFrame.attrs�s
���5�k��r�c��|jS)a�
        Get the properties associated with this pandas object.

        The available flags are

        * :attr:`Flags.allows_duplicate_labels`

        See Also
        --------
        Flags : Flags that apply to pandas objects.
        DataFrame.attrs : Global metadata applying to this dataset.

        Notes
        -----
        "Flags" differ from "metadata". Flags reflect properties of the
        pandas object (the Series or DataFrame). Metadata refer to properties
        of the dataset, and should be stored in :attr:`DataFrame.attrs`.

        Examples
        --------
        >>> df = pd.DataFrame({"A": [1, 2]})
        >>> df.flags
        <Flags(allows_duplicate_labels=True)>

        Flags can be get or set using ``.``

        >>> df.flags.allows_duplicate_labels
        True
        >>> df.flags.allows_duplicate_labels = False

        Or by slicing with a key

        >>> df.flags["allows_duplicate_labels"]
        False
        >>> df.flags["allows_duplicate_labels"] = True
        )r�r�s r��flagsz
NDFrame.flags�s��N�{�{�r�)r�r�c�f�|j|xrt���}|�||jd<|S)a�
        Return a new object with updated flags.

        Parameters
        ----------
        copy : bool, default False
            Specify if a copy of the object should be made.

            .. note::
                The `copy` keyword will change behavior in pandas 3.0.
                `Copy-on-Write
                <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
                will be enabled by default, which means that all methods with a
                `copy` keyword will use a lazy copy mechanism to defer the copy and
                ignore the `copy` keyword. The `copy` keyword will be removed in a
                future version of pandas.

                You can already get the future behavior and improvements through
                enabling copy on write ``pd.options.mode.copy_on_write = True``
        allows_duplicate_labels : bool, optional
            Whether the returned object allows duplicate labels.

        Returns
        -------
        Series or DataFrame
            The same type as the caller.

        See Also
        --------
        DataFrame.attrs : Global metadata applying to this dataset.
        DataFrame.flags : Global flags applying to this object.

        Notes
        -----
        This method returns a new object that's a view on the same data
        as the input. Mutating the input or the output values will be reflected
        in the other.

        This method is intended to be used in method chains.

        "Flags" differ from "metadata". Flags reflect properties of the
        pandas object (the Series or DataFrame). Metadata refer to properties
        of the dataset, and should be stored in :attr:`DataFrame.attrs`.

        Examples
        --------
        >>> df = pd.DataFrame({"A": [1, 2]})
        >>> df.flags.allows_duplicate_labels
        True
        >>> df2 = df.set_flags(allows_duplicate_labels=False)
        >>> df2.flags.allows_duplicate_labels
        False
        ��deepr�)r�rr�)r�r�r��dfs    r��	set_flagszNDFrame.set_flags�s;��x�Y�Y�D�>�)<�)>�%>�Y�
?��"�.�2I�B�H�H�.�/��	r�c�p�|�3t|�}|jdk(rtd|j�d���|S)zvalidate the passed dtype�Vz+compound dtypes are not implemented in the z constructor)rh�kind�NotImplementedError�__name__)r�r�s  r��_validate_dtypezNDFrame._validate_dtype�sK���� ��'�E��z�z�S� �)��!�l�l�^�<�9���
�r�c��t|��)zb
        Used when a manipulation result has the same dimensions as the
        original.
        �rKr�s r��_constructorzNDFrame._constructors��"�$�'�'r�c��tjt|�j�d�tt���|jS)NzV._data is deprecated and will be removed in a future version. Use public APIs instead.��
stacklevel)�warnings�warn�typer��DeprecationWarningrUr�r�s r��_dataz
NDFrame._datas?��	�
�
��D�z�"�"�#�$9�
9��'�)�		
��y�y�r�z!list[Literal['index', 'columns']]�_AXIS_ORDERSr)r�index�rowszdict[Axis, AxisInt]�_AXIS_TO_AXIS_NUMBER�int�_info_axis_number�Literal['index', 'columns']�_info_axis_name�	_AXIS_LENc��|xs|jD�cic]}||j|���}}|j|�|Scc}w)z%Return an axes dictionary for myself.)r�	_get_axis�update)r�r��kwargsr��ds     r��_construct_axes_dictzNDFrame._construct_axes_dict3sO��-1�,E�D�4E�4E�,E�G�,E�a�Q����q�!�
!�,E��G�	
��������	
Hs�Ac�r�	|j|S#t$rtd|�d|j����wxYw)NzNo axis named z for object type )r�KeyError�
ValueErrorr�)r�r�s  r��_get_axis_numberzNDFrame._get_axis_number<sG��	U��+�+�D�1�1���	U��~�d�V�3D�S�\�\�N�S�T�T�	U�s��%6c�B�|j|�}|j|Sr�)rr)r�r��axis_numbers   r��_get_axis_namezNDFrame._get_axis_nameDs%���*�*�4�0������,�,r�c�j�|j|�}|dvsJ�|dk(r|jS|jS)N>rr�r)rr�columns)r�r�rs   r�r
zNDFrame._get_axisJs:���+�+�D�1���f�$�$�$�(�A�-�t�z�z�?�4�<�<�?r�c�T�|j|�}|j}|dk(rd|z
S|S)z'Map the axis to the block_manager axis.�r�)rr)r�r��ndims   r�r�zNDFrame._get_block_manager_axisPs2���#�#�D�)���}�}���1�9��t�8�O��r�c�0�t||�}i}|d}t|j�D]B\}}|�|x}}n	|�d|��}|}|j|�}	|	j	�}
||
_|
||<�Dt
|t�r|}n|j	�}|||<|S)Nr�level_)�getattr�	enumerate�names�get_level_values�	to_seriesrr�r)r�r��
axis_indexr�prefix�i�name�key�level�level_values�s�dindexs            r��_get_axis_resolverszNDFrame._get_axis_resolvers[s����T�4�(�
����a��� ��!1�!1�2�G�A�t���"�"��e�
 ���q�c�*����%�6�6�u�=�L��&�&�(�A� �A�G��A�c�F�3� �j�*�-��F��)�)�+�F���$���r�c��ddlm}i}|jD]"}|j|j	|���$|j�D��cic]\}}t
|t�r�||�|��!c}}Scc}}w)Nr��clean_column_name)�pandas.core.computation.parsingr1rrr.r�r�r)r�r1r�	axis_name�k�vs      r��_get_index_resolverszNDFrame._get_index_resolverszsk��E�,.���*�*�I�
�H�H�T�-�-�i�8�9�+�56�G�G�I�X�I�D�A�q�Z�PQ�SV�EW�!�!�$�a�'�I�X�X��Xs�
A5�&A5c
�l�ddlm}ddlm}t	|t
�r||j�|iSt|j|j��D��cic]O\}}t	|t�s:||�||d|j||j|��j|���Qc}}Scc}}w)z�
        Return the special character free column resolvers of a dataframe.

        Column names with special characters are 'cleaned up' so that they can
        be referred to by backtick quoting.
        Used in :meth:`DataFrame.eval`.
        rr0�r�F)r�rr(r�)r2r1�pandas.core.seriesr�r�rlr(�zipr�_iter_column_arraysrr�dtypesr�)r�r1r�r4r5s     r��_get_cleaned_column_resolversz%NDFrame._get_cleaned_column_resolvers�s���	F�-��d�I�&�%�d�i�i�0�$�7�7��D�L�L�$�*B�*B�*D�E�	
�F���1��a��%�	
�a� �&���T�Z�Z�a�t�{�{�1�~�#��l�4� �
!�F�	
�	
��
s�AB0c�.�t||j�Sr�)r r
r�s r��
_info_axiszNDFrame._info_axis�s���t�T�1�1�2�2r�c��t|jj�dk(ry|jjdjj	�S)NrF)r�r�r��refs�
has_referencer�s r��_is_view_after_cow_rulesz NDFrame._is_view_after_cow_rules�sB���t�y�y��� �A�%���y�y����"�'�'�5�5�7�7r�c�@��t�fd��jD��S)z3
        Return a tuple of axis dimensions
        c3�R�K�|]}t�j|����� y�wr��r�r
��.0r�r�s  �r��	<genexpr>z NDFrame.shape.<locals>.<genexpr>�s"�����G�5F��S�����*�+�5F�s�$')�tuplerr�s`r��shapez
NDFrame.shape�s���
�G�T�5F�5F�G�G�Gr�c�^�|jD�cgc]}|j|���c}Scc}w)z?
        Return index label(s) of the internal NDFrame
        )rr
)r�r�s  r�r�zNDFrame.axes�s-��,0�+<�+<�=�+<�a����q�!�+<�=�=��=s�*c�.�|jjS)a�
        Return an int representing the number of axes / array dimensions.

        Return 1 if Series. Otherwise return 2 if DataFrame.

        See Also
        --------
        ndarray.ndim : Number of array dimensions.

        Examples
        --------
        >>> s = pd.Series({'a': 1, 'b': 2, 'c': 3})
        >>> s.ndim
        1

        >>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})
        >>> df.ndim
        2
        )r�rr�s r�rzNDFrame.ndim�s��,�y�y�~�~�r�c�R�ttj|j��S)a
        Return an int representing the number of elements in this object.

        Return the number of rows if Series. Otherwise return the number of
        rows times number of columns if DataFrame.

        See Also
        --------
        ndarray.size : Number of elements in the array.

        Examples
        --------
        >>> s = pd.Series({'a': 1, 'b': 2, 'c': 3})
        >>> s.size
        3

        >>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})
        >>> df.size
        4
        )r�np�prodrKr�s r��sizezNDFrame.size�s��0�2�7�7�4�:�:�&�'�'r��r�r�c�,�|j||d|��S)a�
        Assign desired index to given axis.

        Indexes for%(extended_summary_sub)s row labels can be changed by assigning
        a list-like or Index.

        Parameters
        ----------
        labels : list-like, Index
            The values for the new index.

        axis : %(axes_single_arg)s, default 0
            The axis to update. The value 0 identifies the rows. For `Series`
            this parameter is unused and defaults to 0.

        copy : bool, default True
            Whether to make a copy of the underlying data.

            .. note::
                The `copy` keyword will change behavior in pandas 3.0.
                `Copy-on-Write
                <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
                will be enabled by default, which means that all methods with a
                `copy` keyword will use a lazy copy mechanism to defer the copy and
                ignore the `copy` keyword. The `copy` keyword will be removed in a
                future version of pandas.

                You can already get the future behavior and improvements through
                enabling copy on write ``pd.options.mode.copy_on_write = True``

        Returns
        -------
        %(klass)s
            An object of type %(klass)s.

        See Also
        --------
        %(klass)s.rename_axis : Alter the name of the index%(see_also_sub)s.
        F)r�r�)�_set_axis_nocheck)r��labelsr�r�s    r��set_axiszNDFrame.set_axis�s��\�%�%�f�d�E��%�M�Mr�r�c��|rt||j|�|�y|j|xrt���}t||j|�|�|S�Nr�)�setattrrr�r)r�rUr�r�r�r�s      r�rTzNDFrame._set_axis_nochecksX����D�$�-�-�d�3�V�<��)�)��!C�.A�.C�*C�)�D�C��C��+�+�D�1�6�:��Jr�c�r�t|�}|jj||�|j�y)z�
        This is called from the cython code when we set the `index` attribute
        directly, e.g. `series.index = [1, 2, 3]`.
        N)r�r�rV�_clear_item_cache)r�r�rUs   r��	_set_axiszNDFrame._set_axis's.���f�%���	�	���4��(���� r�c	��tjdt|�j�dt|�j�d�tt���|j
|�}|j
|�}||k(r|j|xrt���S||||i}t|j�D�cgc]#}|j|j||����%}}|jj||�}	|jj �rt#|jt$�r�t'|	|d|ddd	d
��}
t#|
t$�sJ�t#|jt$�sJ�|jj(dj*|
j(d_|
j(dj*j-|
j(d�t�s|d	ur|
jd��}
|j/|
|
j0�
�}|j3|d��S|j4|	g|��dd	i�j3|d��Scc}w)af
        Interchange axes and swap values axes appropriately.

        .. deprecated:: 2.1.0
            ``swapaxes`` is deprecated and will be removed.
            Please use ``transpose`` instead.

        Returns
        -------
        same as input

        Examples
        --------
        Please see examples for :meth:`DataFrame.transpose`.
        �'zN.swapaxes' is deprecated and will be removed in a future version. Please use 'z.transpose' instead.r�r�rr�NF�block)r�r�r�Tr��swapaxes��methodr�)r�r�rr��
FutureWarningrUrr�r�rangerr
�get�_valuesr`r��is_single_blockr�r�r�r�rA�
add_referencer�r�r�r�)r��axis1�axis2r�r'�j�mappingr4�new_axes�
new_valuesr��outs            r�r`zNDFrame.swapaxes1s%��"	�
�
���T�
�#�#�$�%���:�.�.�/�/C�
E�
�'�)�
	
�
�!�!�%�(���!�!�%�(����6��9�9�$�"D�/B�/D�+D�9�E�E��a��A�,��?D�T�^�^�?T�U�?T�!�D�N�N�7�;�;�q�!�#4�5�?T��U��\�\�*�*�1�a�0�
��9�9�$�$��D�I�I�|�)L�%�����������
�G��g�|�4�4�4��d�i�i��6�6�6�%)�Y�Y�%5�%5�a�%8�%=�%=�G�N�N�1��"��N�N�1��"�"�0�0�����1B�C�&�(�T��->�!�,�,�D�,�1���,�,�W�7�<�<�,�H�C��#�#�D��#�<�<� �t� � ��
�
�
��	
�
�,�t�J�,�
/�	0��/Vs�5(Ir�)r�c�n�|j|�}|j|�}|j||d��S)a�
        Return {klass} with requested index / column level(s) removed.

        Parameters
        ----------
        level : int, str, or list-like
            If a string is given, must be the name of a level
            If list-like, elements must be names or positional indexes
            of levels.

        axis : {{0 or 'index', 1 or 'columns'}}, default 0
            Axis along which the level(s) is removed:

            * 0 or 'index': remove level(s) in column.
            * 1 or 'columns': remove level(s) in row.

            For `Series` this parameter is unused and defaults to 0.

        Returns
        -------
        {klass}
            {klass} with requested index / column level(s) removed.

        Examples
        --------
        >>> df = pd.DataFrame([
        ...     [1, 2, 3, 4],
        ...     [5, 6, 7, 8],
        ...     [9, 10, 11, 12]
        ... ]).set_index([0, 1]).rename_axis(['a', 'b'])

        >>> df.columns = pd.MultiIndex.from_tuples([
        ...     ('c', 'e'), ('d', 'f')
        ... ], names=['level_1', 'level_2'])

        >>> df
        level_1   c   d
        level_2   e   f
        a b
        1 2      3   4
        5 6      7   8
        9 10    11  12

        >>> df.droplevel('a')
        level_1   c   d
        level_2   e   f
        b
        2        3   4
        6        7   8
        10      11  12

        >>> df.droplevel('level_2', axis=1)
        level_1   c   d
        a b
        1 2      3   4
        5 6      7   8
        9 10    11  12
        NrR)r
�	droplevelrV)r�r*r�rU�
new_labelss     r�rqzNDFrame.droplevelqs8��z����%���%�%�e�,�
��}�}�Z�d��}�>�>r�c��||}||=|Sr��)r��item�results   r��popzNDFrame.pop�s���d�����J��
r�c���|�t|j�n|j|�f�|jt	�fd�t|j�D��}t|t�r|j|d��}|S)a�

        Squeeze 1 dimensional axis objects into scalars.

        Series or DataFrames with a single element are squeezed to a scalar.
        DataFrames with a single column or a single row are squeezed to a
        Series. Otherwise the object is unchanged.

        This method is most useful when you don't know if your
        object is a Series or DataFrame, but you do know it has just a single
        column. In that case you can safely call `squeeze` to ensure you have a
        Series.

        Parameters
        ----------
        axis : {0 or 'index', 1 or 'columns', None}, default None
            A specific axis to squeeze. By default, all length-1 axes are
            squeezed. For `Series` this parameter is unused and defaults to `None`.

        Returns
        -------
        DataFrame, Series, or scalar
            The projection after squeezing `axis` or all the axes.

        See Also
        --------
        Series.iloc : Integer-location based indexing for selecting scalars.
        DataFrame.iloc : Integer-location based indexing for selecting Series.
        Series.to_frame : Inverse of DataFrame.squeeze for a
            single-column DataFrame.

        Examples
        --------
        >>> primes = pd.Series([2, 3, 5, 7])

        Slicing might produce a Series with a single value:

        >>> even_primes = primes[primes % 2 == 0]
        >>> even_primes
        0    2
        dtype: int64

        >>> even_primes.squeeze()
        2

        Squeezing objects with more than one value in every axis does nothing:

        >>> odd_primes = primes[primes % 2 == 1]
        >>> odd_primes
        1    3
        2    5
        3    7
        dtype: int64

        >>> odd_primes.squeeze()
        1    3
        2    5
        3    7
        dtype: int64

        Squeezing is even more effective when used with DataFrames.

        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['a', 'b'])
        >>> df
           a  b
        0  1  2
        1  3  4

        Slicing a single column will produce a DataFrame with the columns
        having only one value:

        >>> df_a = df[['a']]
        >>> df_a
           a
        0  1
        1  3

        So the columns can be squeezed down, resulting in a Series:

        >>> df_a.squeeze('columns')
        0    1
        1    3
        Name: a, dtype: int64

        Slicing a single row from a single column will produce a single
        scalar DataFrame:

        >>> df_0a = df.loc[df.index < 1, ['a']]
        >>> df_0a
           a
        0  1

        Squeezing the rows produces a single scalar Series:

        >>> df_0a.squeeze('rows')
        a    1
        Name: 0, dtype: int64

        Squeezing all axes will project directly into a scalar:

        >>> df_0a.squeeze()
        1
        c3�b�K�|]&\}}|�vrt|�dk(rdn
td����(y�w)r�rN)r��slice)rHr'r�r�s   �r�rIz"NDFrame.squeeze.<locals>.<genexpr>"s6������0�D�A�q��$�Y�3�q�6�Q�;��E�$�K�?�0�s�,/�squeezera)
rdrr�ilocrJr!r�r�r�r�)r�r�rvr�s   @r�r{zNDFrame.squeeze�s{���P)-��u�T�^�^�$�4�;P�;P�QU�;V�:X�������%�d�i�i�0��
�
���f�g�&��(�(��i�(�@�F��
r��ignore)rrr�r�r�r*�errorsc��|�|�
|�td��|�|�|�td��|�&td��|r|j|�dk(r|}n|}|j|�|r|n|j|xrt	���}	t||f�D�]\}
}|��
|j
|
�}tj|�}
|�|j|�}t|�s�|jr#|�!|j|�j|�}n|j|�}|dk(rDt||dk(�r3t|�D��cgc]\}}||dk(r|��}}}t|�d���|j!|
|�	�}|	j#||
d
d��|	j%���|r|j'|	�y|	j)|d
��Scc}}w)Nzmust pass an index to rename�:Cannot specify both 'axis' and any of 'index' or 'columns'z<Cannot specify both 'mapper' and any of 'index' or 'columns'r�r��raise���� not found in axis�r*TF�r�r�r��renamera)�	TypeErrorr�*_check_inplace_and_allows_duplicate_labelsr�rr!r
rs�get_rename_function�_get_level_number�callable�	_is_multir#�get_indexer_forr�r�_transform_indexrTr[�_update_inplacer�)r��mapperrrr�r�r�r*r~rv�axis_no�replacements�ax�f�indexer�label�missing_labels�	new_indexs                  r��_renamezNDFrame._rename.s���>�e�m����:�;�;���� 3����P����!��R���
��-�-�d�3�q�8� �����7�7��@� ��d�i�i�T�5W�BU�BW�>W�i�&X��%.��w�/?�%@�!�G�\��#������(�B��*�*�<�8�A�� ��,�,�U�3���L�)��<�<�E�$5� �1�1�%�8�H�H��V�G� �0�0��>�G��W�$��W�W��]�-C�)D�-6�l�,C�&�,C�L�E�5�"�5�>�R�/��,C�#�&�
#�n�%5�5G�#H�I�I��+�+�A�U�+�;�I��$�$�Y�W�d�QV�$�W��$�$�&�7&A�:�� � ��(���&�&�t�H�&�=�=��&s�>G.)rrr�r�r�c��yr�rt�r�r�rrr�r�r�s       r��rename_axiszNDFrame.rename_axisv���	r�)rrr�r�c��yr�rtr�s       r�r�zNDFrame.rename_axis�r�r�c��yr�rtr�s       r�r�zNDFrame.rename_axis�r�r�c��||d�}|�|j|�}t|d�}|rt�rd}|tjurHt|�xst
|�xrt|�}|r|j||||��Std��|r|n|j|��}	t|j�D]�}|j|j|��}
|
tjur�6t|
�xst
|
�xrt|
�}|r|
}nEtj |
�}|j#|�j$}
|
D�cgc]
}||���}}|	j||d|����|s|	Sycc}w)	a
        Set the name of the axis for the index or columns.

        Parameters
        ----------
        mapper : scalar, list-like, optional
            Value to set the axis name attribute.
        index, columns : scalar, list-like, dict-like or function, optional
            A scalar, list-like, dict-like or functions transformations to
            apply to that axis' values.
            Note that the ``columns`` parameter is not allowed if the
            object is a Series. This parameter only apply for DataFrame
            type objects.

            Use either ``mapper`` and ``axis`` to
            specify the axis to target with ``mapper``, or ``index``
            and/or ``columns``.
        axis : {0 or 'index', 1 or 'columns'}, default 0
            The axis to rename. For `Series` this parameter is unused and defaults to 0.
        copy : bool, default None
            Also copy underlying data.

            .. note::
                The `copy` keyword will change behavior in pandas 3.0.
                `Copy-on-Write
                <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
                will be enabled by default, which means that all methods with a
                `copy` keyword will use a lazy copy mechanism to defer the copy and
                ignore the `copy` keyword. The `copy` keyword will be removed in a
                future version of pandas.

                You can already get the future behavior and improvements through
                enabling copy on write ``pd.options.mode.copy_on_write = True``
        inplace : bool, default False
            Modifies the object directly, instead of creating a new Series
            or DataFrame.

        Returns
        -------
        Series, DataFrame, or None
            The same type as the caller or None if ``inplace=True``.

        See Also
        --------
        Series.rename : Alter Series index labels or name.
        DataFrame.rename : Alter DataFrame index labels or name.
        Index.rename : Set new names on index.

        Notes
        -----
        ``DataFrame.rename_axis`` supports two calling conventions

        * ``(index=index_mapper, columns=columns_mapper, ...)``
        * ``(mapper, axis={'index', 'columns'}, ...)``

        The first calling convention will only modify the names of
        the index and/or the names of the Index object that is the columns.
        In this case, the parameter ``copy`` is ignored.

        The second calling convention will modify the names of the
        corresponding index if mapper is a list or a scalar.
        However, if mapper is dict-like or a function, it will use the
        deprecated behavior of modifying the axis *labels*.

        We *highly* recommend using keyword arguments to clarify your
        intent.

        Examples
        --------
        **Series**

        >>> s = pd.Series(["dog", "cat", "monkey"])
        >>> s
        0       dog
        1       cat
        2    monkey
        dtype: object
        >>> s.rename_axis("animal")
        animal
        0    dog
        1    cat
        2    monkey
        dtype: object

        **DataFrame**

        >>> df = pd.DataFrame({"num_legs": [4, 4, 2],
        ...                    "num_arms": [0, 0, 2]},
        ...                   ["dog", "cat", "monkey"])
        >>> df
                num_legs  num_arms
        dog            4         0
        cat            4         0
        monkey         2         2
        >>> df = df.rename_axis("animal")
        >>> df
                num_legs  num_arms
        animal
        dog            4         0
        cat            4         0
        monkey         2         2
        >>> df = df.rename_axis("limbs", axis="columns")
        >>> df
        limbs   num_legs  num_arms
        animal
        dog            4         0
        cat            4         0
        monkey         2         2

        **MultiIndex**

        >>> df.index = pd.MultiIndex.from_product([['mammal'],
        ...                                        ['dog', 'cat', 'monkey']],
        ...                                       names=['type', 'name'])
        >>> df
        limbs          num_legs  num_arms
        type   name
        mammal dog            4         0
               cat            4         0
               monkey         2         2

        >>> df.rename_axis(index={'type': 'class'})
        limbs          num_legs  num_arms
        class  name
        mammal dog            4         0
               cat            4         0
               monkey         2         2

        >>> df.rename_axis(columns=str.upper)
        LIMBS          num_legs  num_arms
        type   name
        mammal dog            4         0
               cat            4         0
               monkey         2         2
        �rrNr�Fr�z,Use `.rename` to alter labels with a mapper.r�T)rrXrr�
no_defaultrgrcra�_set_axis_namerr�rdrrerrsr�r
r")r�r�rrr�r�r�r��
non_mapperrvr5�newnamesr��curnamesr(s               r�r�zNDFrame.rename_axis�s���b�7�3�����(�(��.�D�%�g�y�9���'�)��D�����'�"�6�*���V�$�A�\�&�-A�)A�
���*�*���w�T�+���!�!O�P�P�%�T�$�)�)��)�*>�F��d�n�n�-���H�H�T�0�0��6�7������&��&�q�\�V�l�1�o�.U�l�ST�o�BU�
�� �H��2�2�1�5�A�#�~�~�d�3�9�9�H�4<�=�H�D��$��H�H�=��%�%�h�T�4�d�%�S�.���
���	 >s�
E:c���|j|�}|j|�j|�}t|d�}|r|n|j	|��}|dk(r||_n||_|s|Sy)at
        Set the name(s) of the axis.

        Parameters
        ----------
        name : str or list of str
            Name(s) to set.
        axis : {0 or 'index', 1 or 'columns'}, default 0
            The axis to set the label. The value 0 or 'index' specifies index,
            and the value 1 or 'columns' specifies columns.
        inplace : bool, default False
            If `True`, do operation inplace and return None.
        copy:
            Whether to make a copy of the result.

        Returns
        -------
        Series, DataFrame, or None
            The same type as the caller or `None` if `inplace` is `True`.

        See Also
        --------
        DataFrame.rename : Alter the axis labels of :class:`DataFrame`.
        Series.rename : Alter the index labels or set the index name
            of :class:`Series`.
        Index.rename : Set the name of :class:`Index` or :class:`MultiIndex`.

        Examples
        --------
        >>> df = pd.DataFrame({"num_legs": [4, 4, 2]},
        ...                   ["dog", "cat", "monkey"])
        >>> df
                num_legs
        dog            4
        cat            4
        monkey         2
        >>> df._set_axis_name("animal")
                num_legs
        animal
        dog            4
        cat            4
        monkey         2
        >>> df.index = pd.MultiIndex.from_product(
        ...                [["mammal"], ['dog', 'cat', 'monkey']])
        >>> df._set_axis_name(["type", "name"])
                       num_legs
        type   name
        mammal dog        4
               cat        4
               monkey     2
        r�r�rN)rr
�	set_namesrXr�rr)r�r(r�r�r��idx�renameds       r�r�zNDFrame._set_axis_nameXsp��n�$�$�T�*���n�n�T�"�,�,�T�2��%�g�y�9��!�$�t�y�y�d�y�';���1�9��G�M�!�G�O���N�r�c�D���t��fd��jD��S)Nc3�|�K�|]3}�j|�j�j|�����5y�wr�)r
�equals)rHr��otherr�s  ��r�rIz(NDFrame._indexed_same.<locals>.<genexpr>�s3�����
�BS�Q�D�N�N�1��$�$�U�_�_�Q�%7�8�BS�s�9<)�allr�r�r�s``r��
_indexed_samezNDFrame._indexed_same�s#����
�BF�BS�BS�
�
�	
r�r�c���t|t|��st|t|��sytt|�}|jj|j�S)a8
        Test whether two objects contain the same elements.

        This function allows two Series or DataFrames to be compared against
        each other to see if they have the same shape and elements. NaNs in
        the same location are considered equal.

        The row/column index do not need to have the same type, as long
        as the values are considered equal. Corresponding columns and
        index must be of the same dtype.

        Parameters
        ----------
        other : Series or DataFrame
            The other Series or DataFrame to be compared with the first.

        Returns
        -------
        bool
            True if all elements are the same in both objects, False
            otherwise.

        See Also
        --------
        Series.eq : Compare two Series objects of the same length
            and return a Series where each element is True if the element
            in each Series is equal, False otherwise.
        DataFrame.eq : Compare two DataFrame objects of the same shape and
            return a DataFrame where each element is True if the respective
            element in each DataFrame is equal, False otherwise.
        testing.assert_series_equal : Raises an AssertionError if left and
            right are not equal. Provides an easy interface to ignore
            inequality in dtypes, indexes and precision among others.
        testing.assert_frame_equal : Like assert_series_equal, but targets
            DataFrames.
        numpy.array_equal : Return True if two arrays have the same shape
            and elements, False otherwise.

        Examples
        --------
        >>> df = pd.DataFrame({1: [10], 2: [20]})
        >>> df
            1   2
        0  10  20

        DataFrames df and exactly_equal have the same types and values for
        their elements and column labels, which will return True.

        >>> exactly_equal = pd.DataFrame({1: [10], 2: [20]})
        >>> exactly_equal
            1   2
        0  10  20
        >>> df.equals(exactly_equal)
        True

        DataFrames df and different_column_type have the same element
        types and values, but have different types for the column labels,
        which will still return True.

        >>> different_column_type = pd.DataFrame({1.0: [10], 2.0: [20]})
        >>> different_column_type
           1.0  2.0
        0   10   20
        >>> df.equals(different_column_type)
        True

        DataFrames df and different_data_type have different types for the
        same values for their elements, and will return False even though
        their column labels are the same values and types.

        >>> different_data_type = pd.DataFrame({1: [10.0], 2: [20.0]})
        >>> different_data_type
              1     2
        0  10.0  20.0
        >>> df.equals(different_data_type)
        False
        F)r�rr
r�r�r�r�s  r�r�zNDFrame.equals�sH��^�5�$�t�*�-��D�$�u�+�1N���W�e�$���y�y����
�
�+�+r�c��dd�}|jj|�}|j||j��}|j	|d��S)Nc��t|j�rtj|�Stj|�Sr�)r`r��operator�inv�neg�r�s r��blk_funcz!NDFrame.__neg__.<locals>.blk_func�s0���V�\�\�*� �|�|�F�+�+�
 �|�|�F�+�+r�r��__neg__ra�r�r�r��applyr�r�r��r�r��new_data�ress    r�r�zNDFrame.__neg__�sJ��
	,��9�9�?�?�8�,���(�(���
�
�(�F������Y��7�7r�c��dd�}|jj|�}|j||j��}|j	|d��S)Nc�v�t|j�r|j�Stj|�Sr�)r`r�r�r��posr�s r�r�z!NDFrame.__pos__.<locals>.blk_funcs+���V�\�\�*��{�{�}�$�
 �|�|�F�+�+r�r��__pos__rar�r�r�s    r�r�zNDFrame.__pos__sJ��	,��9�9�?�?�8�,���(�(���
�
�(�F������Y��7�7r�c���|js|jd��S|jjtj
�}|j
||j��}|j|d��S)NFr�r��
__invert__ra)	rQr�r�r�r��invertr�r�r�)r�r�r�s   r�r�zNDFrame.__invert__s_���y�y��9�9�%�9�(�(��9�9�?�?�8�?�?�3���(�(���
�
�(�F������\��:�:r�c�F�tdt|�j�d���)NzThe truth value of a zC is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().)rrr�r�s r��__nonzero__zNDFrame.__nonzero__'s-���#�D��J�$7�$7�#8�9C�
C�
�	
r�c�f�tjt|�j�d�tt���|j
�}t|ttjf�rt|�St|�r!tdt|�j����|j�y)a

        Return the bool of a single element Series or DataFrame.

        .. deprecated:: 2.1.0

           bool is deprecated and will be removed in future version of pandas.
           For ``Series`` use ``pandas.Series.item``.

        This must be a boolean scalar value, either True or False. It will raise a
        ValueError if the Series or DataFrame does not have exactly 1 element, or that
        element is not boolean (integer values 0 and 1 will also raise an exception).

        Returns
        -------
        bool
            The value in the Series or DataFrame.

        See Also
        --------
        Series.astype : Change the data type of a Series, including to boolean.
        DataFrame.astype : Change the data type of a DataFrame, including to boolean.
        numpy.bool_ : NumPy boolean data type, used by pandas for boolean values.

        Examples
        --------
        The method will only work for single element objects with a boolean value:

        >>> pd.Series([True]).bool()  # doctest: +SKIP
        True
        >>> pd.Series([False]).bool()  # doctest: +SKIP
        False

        >>> pd.DataFrame({'col': [True]}).bool()  # doctest: +SKIP
        True
        >>> pd.DataFrame({'col': [False]}).bool()  # doctest: +SKIP
        False

        This is an alternative method and will only work
        for single element objects with a boolean value:

        >>> pd.Series([True]).item()  # doctest: +SKIP
        True
        >>> pd.Series([False]).item()  # doctest: +SKIP
        False
        zG.bool is now deprecated and will be removed in future version of pandasr�z0bool cannot act on a non-boolean single element T)r�r�rr�rcrUr{r��boolrO�bool_rgrr�)r�r5s  r�r�zNDFrame.bool0s���`	�
�
��D�z�"�"�#�$*�
*��'�)�		
�
�L�L�N���a�$����)�*���7�N�
�q�\��B���:�&�&�'�)��
�
	
����r�c��|jjtj�}|j	||j
��j
|d��S)a�
        Return a Series/DataFrame with absolute numeric value of each element.

        This function only applies to elements that are all numeric.

        Returns
        -------
        abs
            Series/DataFrame containing the absolute value of each element.

        See Also
        --------
        numpy.absolute : Calculate the absolute value element-wise.

        Notes
        -----
        For ``complex`` inputs, ``1.2 + 1j``, the absolute value is
        :math:`\sqrt{ a^2 + b^2 }`.

        Examples
        --------
        Absolute numeric values in a Series.

        >>> s = pd.Series([-1.10, 2, -3.33, 4])
        >>> s.abs()
        0    1.10
        1    2.00
        2    3.33
        3    4.00
        dtype: float64

        Absolute numeric values in a Series with complex numbers.

        >>> s = pd.Series([1.2 + 1j])
        >>> s.abs()
        0    1.56205
        dtype: float64

        Absolute numeric values in a Series with a Timedelta element.

        >>> s = pd.Series([pd.Timedelta('1 days')])
        >>> s.abs()
        0   1 days
        dtype: timedelta64[ns]

        Select rows with data closest to certain value using argsort (from
        `StackOverflow <https://stackoverflow.com/a/17758115>`__).

        >>> df = pd.DataFrame({
        ...     'a': [4, 5, 6, 7],
        ...     'b': [10, 20, 30, 40],
        ...     'c': [100, 50, -30, -50]
        ... })
        >>> df
             a    b    c
        0    4   10  100
        1    5   20   50
        2    6   30  -30
        3    7   40  -50
        >>> df.loc[(df.c - 43).abs().argsort()]
             a    b    c
        1    5   20   50
        0    4   10  100
        2    6   30  -30
        3    7   40  -50
        r��abs)r()r�r�rOr�r�r�r�)r��res_mgrs  r�r�zNDFrame.absssM��H�)�)�/�/�"�&�&�)���)�)�'����)�E�R�R��u�S�
�	
r�c�"�|j�Sr�)r�r�s r��__abs__zNDFrame.__abs__�s���x�x�z�r�c�F�|j|�j|d��S)N�	__round__ra)�roundr�)r��decimalss  r�r�zNDFrame.__round__�s!���z�z�(�#�0�0��k�0�J�Jr�c��|j|�}|duxr>t|�xr1||j|jvxr|j	||��S)a|
        Test whether a key is a level reference for a given axis.

        To be considered a level reference, `key` must be a string that:
          - (axis=0): Matches the name of an index level and does NOT match
            a column label.
          - (axis=1): Matches the name of a column level and does NOT match
            an index label.

        Parameters
        ----------
        key : Hashable
            Potential level name for the given axis
        axis : int, default 0
            Axis that levels are associated with (0 for index, 1 for columns)

        Returns
        -------
        is_level : bool
        Nr�)rrmr�r"�_is_label_reference)r�r)r��axis_ints    r��_is_level_referencezNDFrame._is_level_reference�sk��,�(�(��.��
�t�O�
A��C� �
A��t�y�y��*�0�0�0�
A��,�,�S�x�,�@�@�		
r�c������j|���fd�t�j�D�}�duxr"t��xrt	��fd�|D��S)aR
        Test whether a key is a label reference for a given axis.

        To be considered a label reference, `key` must be a string that:
          - (axis=0): Matches a column label
          - (axis=1): Matches an index label

        Parameters
        ----------
        key : Hashable
            Potential label name, i.e. Index entry.
        axis : int, default 0
            Axis perpendicular to the axis that labels are associated with
            (0 means search for column labels, 1 means search for index labels)

        Returns
        -------
        is_label: bool
        c3�.�K�|]}|�k7s�	|���y�wr�rt�rHr�r�s  �r�rIz.NDFrame._is_label_reference.<locals>.<genexpr>������K�#8�R�B�(�N�b�#8���
�Nc3�@�K�|]}��j|v���y�wr�r��rHr�r)r�s  ��r�rIz.NDFrame._is_label_reference.<locals>.<genexpr>������>�:�R�C�4�9�9�R�=�(�:���)rrdrrm�any)r�r)r��
other_axesr�s``  @r�r�zNDFrame._is_label_reference�sV���*�(�(��.��K�5����#8�K�
�
�t�O�
?��C� �
?��>�:�>�>�	
r�c�R�|j||��xs|j||��S)a8
        Test whether a key is a label or level reference for a given axis.

        To be considered either a label or a level reference, `key` must be a
        string that:
          - (axis=0): Matches a column label or an index level
          - (axis=1): Matches an index label or a column level

        Parameters
        ----------
        key : Hashable
            Potential label or level name
        axis : int, default 0
            Axis that levels are associated with (0 for index, 1 for columns)

        Returns
        -------
        bool
        r�)r�r�)r�r)r�s   r��_is_label_or_level_referencez$NDFrame._is_label_or_level_reference	s9��*�'�'��$�'�7�
�4�;S�;S��d�<T�<
�	
r�c�R���	��j|��	�	fd�t�j�D�}��st��rg��j�	j
vrKt
��fd�|D��r5�	dk(rdnd\}}�	dk(rdnd\}}d��d|�d	|�d
|�d	|�d�}t|��yyyy)a�
        Check whether `key` is ambiguous.

        By ambiguous, we mean that it matches both a level of the input
        `axis` and a label of the other axis.

        Parameters
        ----------
        key : Hashable
            Label or level name.
        axis : int, default 0
            Axis that levels are associated with (0 for index, 1 for columns).

        Raises
        ------
        ValueError: `key` is ambiguous
        c3�.�K�|]}|�k7s�	|���y�wr�rtr�s  �r�rIz:NDFrame._check_label_or_level_ambiguity.<locals>.<genexpr>7r�r�Nc3�@�K�|]}��j|v���y�wr�r�r�s  ��r�rIz:NDFrame._check_label_or_level_ambiguity.<locals>.<genexpr>=r�r�r)�anr)r��columnr^z
' is both � z level and z label, which is ambiguous.)rrdrrmr�r"r�r)
r�r)r�r��
level_article�
level_type�
label_article�
label_type�msgr�s
``       @r��_check_label_or_level_ambiguityz'NDFrame._check_label_or_level_ambiguity"s����(�(�(��.��K�5����#8�K�
�
�O��C� ��t�y�y��*�0�0�0��>�:�>�>�$,�q�=��o�
&�M�:�
$,�q�=��o�
&�M�:�
�C�5�
�=�/��:�,�k� �/��:�,�.I�K�
��S�/�!�?�1�!�
r�c�H�|j|�}t|j�D�cgc]
}||k7s�	|��}}|j||��r4|j	||��|j||d��j}nG|j||��r)|j|j|�j}nt|��|jdkDrF|r%t|j|d�t�rd}nd}|dk(rdnd}td|�d	|�d
|����|Scc}w)a�
        Return a 1-D array of values associated with `key`, a label or level
        from the given `axis`.

        Retrieval logic:
          - (axis=0): Return column values if `key` matches a column label.
            Otherwise return index level values if `key` matches an index
            level.
          - (axis=1): Return row values if `key` matches an index label.
            Otherwise return column level values if 'key' matches a column
            level

        Parameters
        ----------
        key : Hashable
            Label or level name.
        axis : int, default 0
            Axis that levels are associated with (0 for index, 1 for columns)

        Returns
        -------
        np.ndarray or ExtensionArray

        Raises
        ------
        KeyError
            if `key` matches neither a label nor a level
        ValueError
            if `key` matches multiple labels
        r�rr�zX
For a multi-index, the label must be a tuple with elements corresponding to each level.�r�rzThe z label 'z' is not unique.)rrdrr�r��xsrfr�r�r#rrr�r
rr)r�r)r�r�r�r��
multi_message�label_axis_names        r��_get_label_or_level_valuesz"NDFrame._get_label_or_level_valuesNs.��@�$�$�T�*��#(����#8�G�#8�R�B�$�J�b�#8�
�G��#�#�C�d�#�3��0�0��4�0�@��W�W�S�z�!�}�W�5�=�=�F�
�
%�
%�c��
%�
5��Y�Y�t�_�5�5�c�:�B�B�F��3�-���;�;��?��j����
�1�
�)F�
�S�G��!#�
�*.�!�)�h��O����'�x��u�4D�]�O�T��
��
��5Hs
�
D�Dc���|j|�}tj|�}|D�cgc]}|j||��r�|��}}|rt	d|�d|����|D�cgc]}|j||��s�|��}}|D�cgc]}|j||��r�|��}}|j
d��}|dk(r.|r|j|dd��|r|j|d	d�
�|S|r_t|jt�r!|jj|�|_
n$t|jj�|_
|r|j|dd�
�|Scc}wcc}wcc}w)a	
        Drop labels and/or levels for the given `axis`.

        For each key in `keys`:
          - (axis=0): If key matches a column label then drop the column.
            Otherwise if key matches an index level then drop the level.
          - (axis=1): If key matches an index label then drop the row.
            Otherwise if key matches a column level then drop the level.

        Parameters
        ----------
        keys : str or list of str
            labels or levels to drop
        axis : int, default 0
            Axis that levels are associated with (0 for index, 1 for columns)

        Returns
        -------
        dropped: DataFrame

        Raises
        ------
        ValueError
            if any `keys` match neither a label nor a level
        r�z;The following keys are not valid labels or levels for axis z: Fr�rT)�dropr�r��r�r�)rrs�maybe_make_listr�rr�r��reset_indexr�r�rrrqr�rQ)r��keysr�r4�invalid_keys�levels_to_drop�labels_to_drop�droppeds        r��_drop_labels_or_levelszNDFrame._drop_labels_or_levels�s���6�$�$�T�*���%�%�d�+���
��!�4�#D�#D�Q�T�#D�#R�A�t�	�
���#�#'�&��<�.�:��
�&*�T�T��T�-E�-E�a�d�-E�-S�!�T��T�%)�X�T���1I�1I�!�RV�1I�1W�!�T��X�
�)�)��)�'���1�9���#�#�N��t�#�L�����^�!�T��B� ����g�o�o�z�:�&-�o�o�&?�&?��&O�G�O�'1����1E�1E�&F�G�O�����^�!�T��B����W
��U��Xs#�E!�E!�!E&�:E&�E+�E+zClassVar[None]�__hash__c�,�t|j�S)a'
        Iterate over info axis.

        Returns
        -------
        iterator
            Info axis as iterator.

        Examples
        --------
        >>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
        >>> for x in df:
        ...     print(x)
        A
        B
        )�iterr?r�s r��__iter__zNDFrame.__iter__�s��"�D�O�O�$�$r�c��|jS)a�
        Get the 'info axis' (see Indexing for more).

        This is index for Series, columns for DataFrame.

        Returns
        -------
        Index
            Info axis.

        Examples
        --------
        >>> d = pd.DataFrame(data={'A': [1, 2, 3], 'B': [0, 4, 8]},
        ...                  index=['a', 'b', 'c'])
        >>> d
           A  B
        a  1  0
        b  2  4
        c  3  8
        >>> d.keys()
        Index(['A', 'B'], dtype='object')
        �r?r�s r�r�zNDFrame.keys�s��.���r�c#�@K�|jD]}|||f���
y�w)z�
        Iterate over (label, values) on info axis

        This is index for Series and columns for DataFrame.

        Returns
        -------
        Generator
        Nr	)r��hs  r�r�z
NDFrame.itemss$�������A��T�!�W�*��!�s�c�,�t|j�S)zReturns length of info axis)r�r?r�s r��__len__zNDFrame.__len__s���4�?�?�#�#r�c��||jvS)z#True if the key is in the info axisr	)r�r)s  r��__contains__zNDFrame.__contains__s���d�o�o�%�%r�c�@��t�fd��jD��S)a�
        Indicator whether Series/DataFrame is empty.

        True if Series/DataFrame is entirely empty (no items), meaning any of the
        axes are of length 0.

        Returns
        -------
        bool
            If Series/DataFrame is empty, return True, if not return False.

        See Also
        --------
        Series.dropna : Return series without null values.
        DataFrame.dropna : Return DataFrame with labels on given axis omitted
            where (all or any) data are missing.

        Notes
        -----
        If Series/DataFrame contains only NaNs, it is still not considered empty. See
        the example below.

        Examples
        --------
        An example of an actual empty DataFrame. Notice the index is empty:

        >>> df_empty = pd.DataFrame({'A' : []})
        >>> df_empty
        Empty DataFrame
        Columns: [A]
        Index: []
        >>> df_empty.empty
        True

        If we only have NaNs in our DataFrame, it is not considered empty! We
        will need to drop the NaNs to make the DataFrame empty:

        >>> df = pd.DataFrame({'A' : [np.nan]})
        >>> df
            A
        0 NaN
        >>> df.empty
        False
        >>> df.dropna().empty
        True

        >>> ser_empty = pd.Series({'A' : []})
        >>> ser_empty
        A    []
        dtype: object
        >>> ser_empty.empty
        False
        >>> ser_empty = pd.Series()
        >>> ser_empty.empty
        True
        c3�X�K�|]!}t�j|��dk(���#y�w)rNrFrGs  �r�rIz NDFrame.empty.<locals>.<genexpr>\s'�����J�8I�1�3�t�~�~�a�(�)�Q�.�8I�s�'*)r�rr�s`r��emptyz
NDFrame.empty"s���t�J��8I�8I�J�J�Jr�i��__array_priority__c��|j}tj||��}t|j|j�r�t�r�|jjrnt|jjd|j�rAt|j|j�r!|j�}d|j_|S)Nr�rF)
rfrO�asarrayr[r�rr�rgr<r|�viewr��	writeable)r�r�r�r��arrs     r��	__array__zNDFrame.__array__es��������j�j��u�-���6�<�<����3�#�%��	�	�)�)��d�k�k�.�.�q�1�6�<�<�@�^����c�i�i�F��h�h�j��&+��	�	�#��
r�c�8�tj|||g|��i|��Sr�)rr�array_ufunc)r��ufuncrb�inputsrs     r��__array_ufunc__zNDFrame.__array_ufunc__ws#���$�$�T�5�&�L�6�L�V�L�Lr�c
�$�|jD�cic]}|t||d���}}|j|j|j|j|j
jD�cic]}||j
|��c}d�|�Scc}wcc}w)N)r�r�r�r�r�)r�r r�r�r�r��_keys)r�r4�metas   r��__getstate__zNDFrame.__getstate__�s���37�>�>�B�>�a��7�4��D�)�)�>��B��I�I��I�I�����Z�Z�15���1A�1A�B�1A�A�q�$�*�*�Q�-�'�1A�B�
��

�	
��C��Cs�B�*B
c	��t|t�r||_i|_yt|t��r1d|vrd|vr|j	d�|d<|jd�}|��|jdi�}|�i}tj|d|�|jdddi�}tj|dt|fi|���t|j|jz�}t|�D])}||vs�|dk7s�||}tj|||��+|j�D]!\}}||vs�tj|||��#i|_ytd��t|�d	k(rtd��i|_y)
Nrr�r�r�r�r�Tz(Pre-0.12 pickles are no longer supportedr)r�r�r�r�rwrer�r�r|�setr�r��listr�r�r�r�)r��stater�r�r�r!r4r5s        r��__setstate__zNDFrame.__setstate__�st���e�\�*��D�I�B46���A��t�
$��%��F�%�$7� %�	�	�'� 2��f�
��)�)�F�#�C����	�	�(�B�/���=��E��"�"�4��5�9��	�	�(�-F��,M�N���"�"�4��5��3G��3G�H��4�/�/�$�.�.�@�A���d��A��E�z�a�8�m�!�!�H���*�*�4��A�6�$�
"�K�K�M�D�A�q���}��*�*�4��A�6�*�46���	*�*T�U�U�
��Z�1�_�%�&P�Q�Q�35��r�c�~�ddjtt|���d�}t|�j�d|�d�S)N�[�,�]�(�))�join�mapr�rr�)r��preprs  r��__repr__zNDFrame.__repr__�sA���C�H�H�S��t�4�5�6�a�8���t�*�%�%�&�a��w�a�0�0r�c�T�tjd�dk(r|j�Sy)z�
        Returns a LaTeX representation for a particular object.
        Mainly for use with nbconvert (jupyter notebook conversion to pdf).
        zstyler.render.repr�latexN)r�
get_option�to_latexr�s r��_repr_latex_zNDFrame._repr_latex_�s'�����1�2�g�=��=�=�?�"�r�c���tjd�ra|jtjd��}|jd��}t	t
|�}t
|tj��Sy)zh
        Not a real Jupyter special repr method, but we use the same
        naming convention.
        zdisplay.html.table_schemazdisplay.max_rows�table)�orient)�object_pairs_hookN)	rr4�head�to_jsonr
r�r�collections�OrderedDict)r�r��as_jsons   r��_repr_data_resource_zNDFrame._repr_data_resource_�sa�����8�9��9�9�V�.�.�/A�B�C�D��l�l�'�l�2�G��3��(�G���K�4K�4K�L�L�:r�z3.0r��excel_writer�to_excel)�version�allowed_argsr(�storage_optionsz1.2.0)r�rE�storage_options_versionaddedr�c��|�i}t|t�r|n|j�}ddlm}||||||||||
��	}|j|||	|
||||��y)a�
        Write {klass} to an Excel sheet.

        To write a single {klass} to an Excel .xlsx file it is only necessary to
        specify a target file name. To write to multiple sheets it is necessary to
        create an `ExcelWriter` object with a target file name, and specify a sheet
        in the file to write to.

        Multiple sheets may be written to by specifying unique `sheet_name`.
        With all data written to the file it is necessary to save the changes.
        Note that creating an `ExcelWriter` object with a file name that already
        exists will result in the contents of the existing file being erased.

        Parameters
        ----------
        excel_writer : path-like, file-like, or ExcelWriter object
            File path or existing ExcelWriter.
        sheet_name : str, default 'Sheet1'
            Name of sheet which will contain DataFrame.
        na_rep : str, default ''
            Missing data representation.
        float_format : str, optional
            Format string for floating point numbers. For example
            ``float_format="%.2f"`` will format 0.1234 to 0.12.
        columns : sequence or list of str, optional
            Columns to write.
        header : bool or list of str, default True
            Write out the column names. If a list of string is given it is
            assumed to be aliases for the column names.
        index : bool, default True
            Write row names (index).
        index_label : str or sequence, optional
            Column label for index column(s) if desired. If not specified, and
            `header` and `index` are True, then the index names are used. A
            sequence should be given if the DataFrame uses MultiIndex.
        startrow : int, default 0
            Upper left cell row to dump data frame.
        startcol : int, default 0
            Upper left cell column to dump data frame.
        engine : str, optional
            Write engine to use, 'openpyxl' or 'xlsxwriter'. You can also set this
            via the options ``io.excel.xlsx.writer`` or
            ``io.excel.xlsm.writer``.

        merge_cells : bool, default True
            Write MultiIndex and Hierarchical Rows as merged cells.
        inf_rep : str, default 'inf'
            Representation for infinity (there is no native representation for
            infinity in Excel).
        freeze_panes : tuple of int (length 2), optional
            Specifies the one-based bottommost row and rightmost column that
            is to be frozen.
        {storage_options}

            .. versionadded:: {storage_options_versionadded}
        engine_kwargs : dict, optional
            Arbitrary keyword arguments passed to excel engine.

        See Also
        --------
        to_csv : Write DataFrame to a comma-separated values (csv) file.
        ExcelWriter : Class for writing DataFrame objects into excel sheets.
        read_excel : Read an Excel file into a pandas DataFrame.
        read_csv : Read a comma-separated values (csv) file into DataFrame.
        io.formats.style.Styler.to_excel : Add styles to Excel sheet.

        Notes
        -----
        For compatibility with :meth:`~DataFrame.to_csv`,
        to_excel serializes lists and dicts to strings before writing.

        Once a workbook has been saved it is not possible to write further
        data without rewriting the whole workbook.

        Examples
        --------

        Create, write to and save a workbook:

        >>> df1 = pd.DataFrame([['a', 'b'], ['c', 'd']],
        ...                    index=['row 1', 'row 2'],
        ...                    columns=['col 1', 'col 2'])
        >>> df1.to_excel("output.xlsx")  # doctest: +SKIP

        To specify the sheet name:

        >>> df1.to_excel("output.xlsx",
        ...              sheet_name='Sheet_name_1')  # doctest: +SKIP

        If you wish to write to more than one sheet in the workbook, it is
        necessary to specify an ExcelWriter object:

        >>> df2 = df1.copy()
        >>> with pd.ExcelWriter('output.xlsx') as writer:  # doctest: +SKIP
        ...     df1.to_excel(writer, sheet_name='Sheet_name_1')
        ...     df2.to_excel(writer, sheet_name='Sheet_name_2')

        ExcelWriter can also be used to append to an existing Excel file:

        >>> with pd.ExcelWriter('output.xlsx',
        ...                     mode='a') as writer:  # doctest: +SKIP
        ...     df1.to_excel(writer, sheet_name='Sheet_name_3')

        To set the library that is used to write the Excel file,
        you can pass the `engine` keyword (the default engine is
        automatically chosen depending on the file extension):

        >>> df1.to_excel('output1.xlsx', engine='xlsxwriter')  # doctest: +SKIP
        Nr)�ExcelFormatter)�na_rep�cols�header�float_formatr�index_label�merge_cells�inf_rep)�
sheet_name�startrow�startcol�freeze_panes�enginerE�
engine_kwargs)r�rk�to_frame�pandas.io.formats.excelrH�write)r�rArPrIrLrrKrrMrQrRrTrNrOrSrErUr�rH�	formatters                    r�rBzNDFrame.to_excel�sy��R� ��M���l�3�T������:�"�����%��#�#��

�	�	����!���%��+�'�	�		
r��path_or_bufr<�compression_options)rEr[�inferc��ddlm}|�|dk(rd}n|�d}tj|�|xsd}|j	||||||||||	|
|||
��S)a
        Convert the object to a JSON string.

        Note NaN's and None will be converted to null and datetime objects
        will be converted to UNIX timestamps.

        Parameters
        ----------
        path_or_buf : str, path object, file-like object, or None, default None
            String, path object (implementing os.PathLike[str]), or file-like
            object implementing a write() function. If None, the result is
            returned as a string.
        orient : str
            Indication of expected JSON string format.

            * Series:

                - default is 'index'
                - allowed values are: {{'split', 'records', 'index', 'table'}}.

            * DataFrame:

                - default is 'columns'
                - allowed values are: {{'split', 'records', 'index', 'columns',
                  'values', 'table'}}.

            * The format of the JSON string:

                - 'split' : dict like {{'index' -> [index], 'columns' -> [columns],
                  'data' -> [values]}}
                - 'records' : list like [{{column -> value}}, ... , {{column -> value}}]
                - 'index' : dict like {{index -> {{column -> value}}}}
                - 'columns' : dict like {{column -> {{index -> value}}}}
                - 'values' : just the values array
                - 'table' : dict like {{'schema': {{schema}}, 'data': {{data}}}}

                Describing the data, where data component is like ``orient='records'``.

        date_format : {{None, 'epoch', 'iso'}}
            Type of date conversion. 'epoch' = epoch milliseconds,
            'iso' = ISO8601. The default depends on the `orient`. For
            ``orient='table'``, the default is 'iso'. For all other orients,
            the default is 'epoch'.
        double_precision : int, default 10
            The number of decimal places to use when encoding
            floating point values. The possible maximal value is 15.
            Passing double_precision greater than 15 will raise a ValueError.
        force_ascii : bool, default True
            Force encoded string to be ASCII.
        date_unit : str, default 'ms' (milliseconds)
            The time unit to encode to, governs timestamp and ISO8601
            precision.  One of 's', 'ms', 'us', 'ns' for second, millisecond,
            microsecond, and nanosecond respectively.
        default_handler : callable, default None
            Handler to call if object cannot otherwise be converted to a
            suitable format for JSON. Should receive a single argument which is
            the object to convert and return a serialisable object.
        lines : bool, default False
            If 'orient' is 'records' write out line-delimited json format. Will
            throw ValueError if incorrect 'orient' since others are not
            list-like.
        {compression_options}

            .. versionchanged:: 1.4.0 Zstandard support.

        index : bool or None, default None
            The index is only used when 'orient' is 'split', 'index', 'column',
            or 'table'. Of these, 'index' and 'column' do not support
            `index=False`.

        indent : int, optional
           Length of whitespace used to indent each record.

        {storage_options}

        mode : str, default 'w' (writing)
            Specify the IO mode for output when supplying a path_or_buf.
            Accepted args are 'w' (writing) and 'a' (append) only.
            mode='a' is only supported when lines is True and orient is 'records'.

        Returns
        -------
        None or str
            If path_or_buf is None, returns the resulting json format as a
            string. Otherwise returns None.

        See Also
        --------
        read_json : Convert a JSON string to pandas object.

        Notes
        -----
        The behavior of ``indent=0`` varies from the stdlib, which does not
        indent the output but does insert newlines. Currently, ``indent=0``
        and the default ``indent=None`` are equivalent in pandas, though this
        may change in a future release.

        ``orient='table'`` contains a 'pandas_version' field under 'schema'.
        This stores the version of `pandas` used in the latest revision of the
        schema.

        Examples
        --------
        >>> from json import loads, dumps
        >>> df = pd.DataFrame(
        ...     [["a", "b"], ["c", "d"]],
        ...     index=["row 1", "row 2"],
        ...     columns=["col 1", "col 2"],
        ... )

        >>> result = df.to_json(orient="split")
        >>> parsed = loads(result)
        >>> dumps(parsed, indent=4)  # doctest: +SKIP
        {{
            "columns": [
                "col 1",
                "col 2"
            ],
            "index": [
                "row 1",
                "row 2"
            ],
            "data": [
                [
                    "a",
                    "b"
                ],
                [
                    "c",
                    "d"
                ]
            ]
        }}

        Encoding/decoding a Dataframe using ``'records'`` formatted JSON.
        Note that index labels are not preserved with this encoding.

        >>> result = df.to_json(orient="records")
        >>> parsed = loads(result)
        >>> dumps(parsed, indent=4)  # doctest: +SKIP
        [
            {{
                "col 1": "a",
                "col 2": "b"
            }},
            {{
                "col 1": "c",
                "col 2": "d"
            }}
        ]

        Encoding/decoding a Dataframe using ``'index'`` formatted JSON:

        >>> result = df.to_json(orient="index")
        >>> parsed = loads(result)
        >>> dumps(parsed, indent=4)  # doctest: +SKIP
        {{
            "row 1": {{
                "col 1": "a",
                "col 2": "b"
            }},
            "row 2": {{
                "col 1": "c",
                "col 2": "d"
            }}
        }}

        Encoding/decoding a Dataframe using ``'columns'`` formatted JSON:

        >>> result = df.to_json(orient="columns")
        >>> parsed = loads(result)
        >>> dumps(parsed, indent=4)  # doctest: +SKIP
        {{
            "col 1": {{
                "row 1": "a",
                "row 2": "c"
            }},
            "col 2": {{
                "row 1": "b",
                "row 2": "d"
            }}
        }}

        Encoding/decoding a Dataframe using ``'values'`` formatted JSON:

        >>> result = df.to_json(orient="values")
        >>> parsed = loads(result)
        >>> dumps(parsed, indent=4)  # doctest: +SKIP
        [
            [
                "a",
                "b"
            ],
            [
                "c",
                "d"
            ]
        ]

        Encoding with Table Schema:

        >>> result = df.to_json(orient="table")
        >>> parsed = loads(result)
        >>> dumps(parsed, indent=4)  # doctest: +SKIP
        {{
            "schema": {{
                "fields": [
                    {{
                        "name": "index",
                        "type": "string"
                    }},
                    {{
                        "name": "col 1",
                        "type": "string"
                    }},
                    {{
                        "name": "col 2",
                        "type": "string"
                    }}
                ],
                "primaryKey": [
                    "index"
                ],
                "pandas_version": "1.4.0"
            }},
            "data": [
                {{
                    "index": "row 1",
                    "col 1": "a",
                    "col 2": "b"
                }},
                {{
                    "index": "row 2",
                    "col 1": "c",
                    "col 2": "d"
                }}
            ]
        }}
        r)�jsonr8�iso�epoch)rZr�r9�date_format�double_precision�force_ascii�	date_unit�default_handler�lines�compressionr�indentrE�mode)�	pandas.ior^r�is_nonnegative_intr<)r�rZr9rarbrcrdrerfrgrrhrErir^s               r�r<zNDFrame.to_json|	s|��P	#���6�W�#4��K�
�
 �!�K��!�!�&�)���1���|�|�#���#�-�#��+��#���+���
�	
r��to_hdfc�P�ddlm}|j||||||||||	|
|||
|��y)ap
        Write the contained data to an HDF5 file using HDFStore.

        Hierarchical Data Format (HDF) is self-describing, allowing an
        application to interpret the structure and contents of a file with
        no outside information. One HDF file can hold a mix of related objects
        which can be accessed as a group or as individual objects.

        In order to add another DataFrame or Series to an existing HDF file
        please use append mode and a different a key.

        .. warning::

           One can store a subclass of ``DataFrame`` or ``Series`` to HDF5,
           but the type of the subclass is lost upon storing.

        For more information see the :ref:`user guide <io.hdf5>`.

        Parameters
        ----------
        path_or_buf : str or pandas.HDFStore
            File path or HDFStore object.
        key : str
            Identifier for the group in the store.
        mode : {'a', 'w', 'r+'}, default 'a'
            Mode to open file:

            - 'w': write, a new file is created (an existing file with
              the same name would be deleted).
            - 'a': append, an existing file is opened for reading and
              writing, and if the file does not exist it is created.
            - 'r+': similar to 'a', but the file must already exist.
        complevel : {0-9}, default None
            Specifies a compression level for data.
            A value of 0 or None disables compression.
        complib : {'zlib', 'lzo', 'bzip2', 'blosc'}, default 'zlib'
            Specifies the compression library to be used.
            These additional compressors for Blosc are supported
            (default if no compressor specified: 'blosc:blosclz'):
            {'blosc:blosclz', 'blosc:lz4', 'blosc:lz4hc', 'blosc:snappy',
            'blosc:zlib', 'blosc:zstd'}.
            Specifying a compression library which is not available issues
            a ValueError.
        append : bool, default False
            For Table formats, append the input data to the existing.
        format : {'fixed', 'table', None}, default 'fixed'
            Possible values:

            - 'fixed': Fixed format. Fast writing/reading. Not-appendable,
              nor searchable.
            - 'table': Table format. Write as a PyTables Table structure
              which may perform worse but allow more flexible operations
              like searching / selecting subsets of the data.
            - If None, pd.get_option('io.hdf.default_format') is checked,
              followed by fallback to "fixed".
        index : bool, default True
            Write DataFrame index as a column.
        min_itemsize : dict or int, optional
            Map column names to minimum string sizes for columns.
        nan_rep : Any, optional
            How to represent null values as str.
            Not allowed with append=True.
        dropna : bool, default False, optional
            Remove missing values.
        data_columns : list of columns or True, optional
            List of columns to create as indexed data columns for on-disk
            queries, or True to use all columns. By default only the axes
            of the object are indexed. See
            :ref:`Query via data columns<io.hdf5-query-data-columns>`. for
            more information.
            Applicable only to format='table'.
        errors : str, default 'strict'
            Specifies how encoding and decoding errors are to be handled.
            See the errors argument for :func:`open` for a full list
            of options.
        encoding : str, default "UTF-8"

        See Also
        --------
        read_hdf : Read from HDF file.
        DataFrame.to_orc : Write a DataFrame to the binary orc format.
        DataFrame.to_parquet : Write a DataFrame to the binary parquet format.
        DataFrame.to_sql : Write to a SQL table.
        DataFrame.to_feather : Write out feather-format for DataFrames.
        DataFrame.to_csv : Write out to a csv file.

        Examples
        --------
        >>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]},
        ...                   index=['a', 'b', 'c'])  # doctest: +SKIP
        >>> df.to_hdf('data.h5', key='df', mode='w')  # doctest: +SKIP

        We can add another object to the same file:

        >>> s = pd.Series([1, 2, 3, 4])  # doctest: +SKIP
        >>> s.to_hdf('data.h5', key='s')  # doctest: +SKIP

        Reading from HDF file:

        >>> pd.read_hdf('data.h5', 'df')  # doctest: +SKIP
        A  B
        a  1  4
        b  2  5
        c  3  6
        >>> pd.read_hdf('data.h5', 's')  # doctest: +SKIP
        0    1
        1    2
        2    3
        3    4
        dtype: int64
        r)�pytables)ri�	complevel�complib�append�formatr�min_itemsize�nan_rep�dropna�data_columnsr~�encodingN)rjrnrl)r�rZr)rirorprqrrrrsrtrurvr~rwrns                r�rlzNDFrame.to_hdf�
sH��H	'�	������������%���%���	�	
r�)r�r(�con�to_sqlc
�D�ddlm}
|
j||||||||||	��
S)a� 
        Write records stored in a DataFrame to a SQL database.

        Databases supported by SQLAlchemy [1]_ are supported. Tables can be
        newly created, appended to, or overwritten.

        Parameters
        ----------
        name : str
            Name of SQL table.
        con : sqlalchemy.engine.(Engine or Connection) or sqlite3.Connection
            Using SQLAlchemy makes it possible to use any DB supported by that
            library. Legacy support is provided for sqlite3.Connection objects. The user
            is responsible for engine disposal and connection closure for the SQLAlchemy
            connectable. See `here                 <https://docs.sqlalchemy.org/en/20/core/connections.html>`_.
            If passing a sqlalchemy.engine.Connection which is already in a transaction,
            the transaction will not be committed.  If passing a sqlite3.Connection,
            it will not be possible to roll back the record insertion.

        schema : str, optional
            Specify the schema (if database flavor supports this). If None, use
            default schema.
        if_exists : {'fail', 'replace', 'append'}, default 'fail'
            How to behave if the table already exists.

            * fail: Raise a ValueError.
            * replace: Drop the table before inserting new values.
            * append: Insert new values to the existing table.

        index : bool, default True
            Write DataFrame index as a column. Uses `index_label` as the column
            name in the table. Creates a table index for this column.
        index_label : str or sequence, default None
            Column label for index column(s). If None is given (default) and
            `index` is True, then the index names are used.
            A sequence should be given if the DataFrame uses MultiIndex.
        chunksize : int, optional
            Specify the number of rows in each batch to be written at a time.
            By default, all rows will be written at once.
        dtype : dict or scalar, optional
            Specifying the datatype for columns. If a dictionary is used, the
            keys should be the column names and the values should be the
            SQLAlchemy types or strings for the sqlite3 legacy mode. If a
            scalar is provided, it will be applied to all columns.
        method : {None, 'multi', callable}, optional
            Controls the SQL insertion clause used:

            * None : Uses standard SQL ``INSERT`` clause (one per row).
            * 'multi': Pass multiple values in a single ``INSERT`` clause.
            * callable with signature ``(pd_table, conn, keys, data_iter)``.

            Details and a sample callable implementation can be found in the
            section :ref:`insert method <io.sql.method>`.

        Returns
        -------
        None or int
            Number of rows affected by to_sql. None is returned if the callable
            passed into ``method`` does not return an integer number of rows.

            The number of returned rows affected is the sum of the ``rowcount``
            attribute of ``sqlite3.Cursor`` or SQLAlchemy connectable which may not
            reflect the exact number of written rows as stipulated in the
            `sqlite3 <https://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor.rowcount>`__ or
            `SQLAlchemy <https://docs.sqlalchemy.org/en/20/core/connections.html#sqlalchemy.engine.CursorResult.rowcount>`__.

            .. versionadded:: 1.4.0

        Raises
        ------
        ValueError
            When the table already exists and `if_exists` is 'fail' (the
            default).

        See Also
        --------
        read_sql : Read a DataFrame from a table.

        Notes
        -----
        Timezone aware datetime columns will be written as
        ``Timestamp with timezone`` type with SQLAlchemy if supported by the
        database. Otherwise, the datetimes will be stored as timezone unaware
        timestamps local to the original timezone.

        Not all datastores support ``method="multi"``. Oracle, for example,
        does not support multi-value insert.

        References
        ----------
        .. [1] https://docs.sqlalchemy.org
        .. [2] https://www.python.org/dev/peps/pep-0249/

        Examples
        --------
        Create an in-memory SQLite database.

        >>> from sqlalchemy import create_engine
        >>> engine = create_engine('sqlite://', echo=False)

        Create a table from scratch with 3 rows.

        >>> df = pd.DataFrame({'name' : ['User 1', 'User 2', 'User 3']})
        >>> df
             name
        0  User 1
        1  User 2
        2  User 3

        >>> df.to_sql(name='users', con=engine)
        3
        >>> from sqlalchemy import text
        >>> with engine.connect() as conn:
        ...    conn.execute(text("SELECT * FROM users")).fetchall()
        [(0, 'User 1'), (1, 'User 2'), (2, 'User 3')]

        An `sqlalchemy.engine.Connection` can also be passed to `con`:

        >>> with engine.begin() as connection:
        ...     df1 = pd.DataFrame({'name' : ['User 4', 'User 5']})
        ...     df1.to_sql(name='users', con=connection, if_exists='append')
        2

        This is allowed to support operations that require that the same
        DBAPI connection is used for the entire operation.

        >>> df2 = pd.DataFrame({'name' : ['User 6', 'User 7']})
        >>> df2.to_sql(name='users', con=engine, if_exists='append')
        2
        >>> with engine.connect() as conn:
        ...    conn.execute(text("SELECT * FROM users")).fetchall()
        [(0, 'User 1'), (1, 'User 2'), (2, 'User 3'),
         (0, 'User 4'), (1, 'User 5'), (0, 'User 6'),
         (1, 'User 7')]

        Overwrite the table with just ``df2``.

        >>> df2.to_sql(name='users', con=engine, if_exists='replace',
        ...            index_label='id')
        2
        >>> with engine.connect() as conn:
        ...    conn.execute(text("SELECT * FROM users")).fetchall()
        [(0, 'User 6'), (1, 'User 7')]

        Use ``method`` to define a callable insertion method to do nothing
        if there's a primary key conflict on a table in a PostgreSQL database.

        >>> from sqlalchemy.dialects.postgresql import insert
        >>> def insert_on_conflict_nothing(table, conn, keys, data_iter):
        ...     # "a" is the primary key in "conflict_table"
        ...     data = [dict(zip(keys, row)) for row in data_iter]
        ...     stmt = insert(table.table).values(data).on_conflict_do_nothing(index_elements=["a"])
        ...     result = conn.execute(stmt)
        ...     return result.rowcount
        >>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", method=insert_on_conflict_nothing)  # doctest: +SKIP
        0

        For MySQL, a callable to update columns ``b`` and ``c`` if there's a conflict
        on a primary key.

        >>> from sqlalchemy.dialects.mysql import insert
        >>> def insert_on_conflict_update(table, conn, keys, data_iter):
        ...     # update columns "b" and "c" on primary key conflict
        ...     data = [dict(zip(keys, row)) for row in data_iter]
        ...     stmt = (
        ...         insert(table.table)
        ...         .values(data)
        ...     )
        ...     stmt = stmt.on_duplicate_key_update(b=stmt.inserted.b, c=stmt.inserted.c)
        ...     result = conn.execute(stmt)
        ...     return result.rowcount
        >>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", method=insert_on_conflict_update)  # doctest: +SKIP
        2

        Specify the dtype (especially useful for integers with missing values).
        Notice that while pandas is forced to store the data as floating point,
        the database supports nullable integers. When fetching the data with
        Python, we get back integer scalars.

        >>> df = pd.DataFrame({"A": [1, None, 2]})
        >>> df
             A
        0  1.0
        1  NaN
        2  2.0

        >>> from sqlalchemy.types import Integer
        >>> df.to_sql(name='integers', con=engine, index=False,
        ...           dtype={"A": Integer()})
        3

        >>> with engine.connect() as conn:
        ...   conn.execute(text("SELECT * FROM integers")).fetchall()
        [(1,), (None,), (2,)]
        r)�sql)�schema�	if_existsrrM�	chunksizer�rb)rjr{ry)r�r(rxr|r}rrMr~r�rbr{s           r�ryzNDFrame.to_sql9s<��h	"��z�z�������#�����
�	
r��path�	to_picklec�*�ddlm}||||||��y)a�
        Pickle (serialize) object to file.

        Parameters
        ----------
        path : str, path object, or file-like object
            String, path object (implementing ``os.PathLike[str]``), or file-like
            object implementing a binary ``write()`` function. File path where
            the pickled object will be stored.
        {compression_options}
        protocol : int
            Int which indicates which protocol should be used by the pickler,
            default HIGHEST_PROTOCOL (see [1]_ paragraph 12.1.2). The possible
            values are 0, 1, 2, 3, 4, 5. A negative value for the protocol
            parameter is equivalent to setting its value to HIGHEST_PROTOCOL.

            .. [1] https://docs.python.org/3/library/pickle.html.

        {storage_options}

        See Also
        --------
        read_pickle : Load pickled pandas object (or any object) from file.
        DataFrame.to_hdf : Write DataFrame to an HDF5 file.
        DataFrame.to_sql : Write DataFrame to a SQL database.
        DataFrame.to_parquet : Write a DataFrame to the binary parquet format.

        Examples
        --------
        >>> original_df = pd.DataFrame({{"foo": range(5), "bar": range(5, 10)}})  # doctest: +SKIP
        >>> original_df  # doctest: +SKIP
           foo  bar
        0    0    5
        1    1    6
        2    2    7
        3    3    8
        4    4    9
        >>> original_df.to_pickle("./dummy.pkl")  # doctest: +SKIP

        >>> unpickled_df = pd.read_pickle("./dummy.pkl")  # doctest: +SKIP
        >>> unpickled_df  # doctest: +SKIP
           foo  bar
        0    0    5
        1    1    6
        2    2    7
        3    3    8
        4    4    9
        r)r�)rg�protocolrEN)�pandas.io.pickler�)r�rrgr�rEr�s      r�r�zNDFrame.to_pickles��~	/����#��+�	
r��to_clipboardc�<�ddlm}|j|f||d�|��y)a�
        Copy object to the system clipboard.

        Write a text representation of object to the system clipboard.
        This can be pasted into Excel, for example.

        Parameters
        ----------
        excel : bool, default True
            Produce output in a csv format for easy pasting into excel.

            - True, use the provided separator for csv pasting.
            - False, write a string representation of the object to the clipboard.

        sep : str, default ``'\t'``
            Field delimiter.
        **kwargs
            These parameters will be passed to DataFrame.to_csv.

        See Also
        --------
        DataFrame.to_csv : Write a DataFrame to a comma-separated values
            (csv) file.
        read_clipboard : Read text from clipboard and pass to read_csv.

        Notes
        -----
        Requirements for your platform.

          - Linux : `xclip`, or `xsel` (with `PyQt4` modules)
          - Windows : none
          - macOS : none

        This method uses the processes developed for the package `pyperclip`. A
        solution to render any output string format is given in the examples.

        Examples
        --------
        Copy the contents of a DataFrame to the clipboard.

        >>> df = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=['A', 'B', 'C'])

        >>> df.to_clipboard(sep=',')  # doctest: +SKIP
        ... # Wrote the following to the system clipboard:
        ... # ,A,B,C
        ... # 0,1,2,3
        ... # 1,4,5,6

        We can omit the index by passing the keyword `index` and setting
        it to false.

        >>> df.to_clipboard(sep=',', index=False)  # doctest: +SKIP
        ... # Wrote the following to the system clipboard:
        ... # A,B,C
        ... # 1,2,3
        ... # 4,5,6

        Using the original `pyperclip` package for any string output format.

        .. code-block:: python

           import pyperclip
           html = df.style.to_html()
           pyperclip.copy(html)
        r)�
clipboards)�excel�sepN)rjr�r�)r�r�r�rr�s     r�r�zNDFrame.to_clipboardes$��P	)��
����E�E�s�E�f�Er�c��td�}|jdk(r|jj|�S|jj|�S)at
        Return an xarray object from the pandas object.

        Returns
        -------
        xarray.DataArray or xarray.Dataset
            Data in the pandas structure converted to Dataset if the object is
            a DataFrame, or a DataArray if the object is a Series.

        See Also
        --------
        DataFrame.to_hdf : Write DataFrame to an HDF5 file.
        DataFrame.to_parquet : Write a DataFrame to the binary parquet format.

        Notes
        -----
        See the `xarray docs <https://xarray.pydata.org/en/stable/>`__

        Examples
        --------
        >>> df = pd.DataFrame([('falcon', 'bird', 389.0, 2),
        ...                    ('parrot', 'bird', 24.0, 2),
        ...                    ('lion', 'mammal', 80.5, 4),
        ...                    ('monkey', 'mammal', np.nan, 4)],
        ...                   columns=['name', 'class', 'max_speed',
        ...                            'num_legs'])
        >>> df
             name   class  max_speed  num_legs
        0  falcon    bird      389.0         2
        1  parrot    bird       24.0         2
        2    lion  mammal       80.5         4
        3  monkey  mammal        NaN         4

        >>> df.to_xarray()  # doctest: +SKIP
        <xarray.Dataset>
        Dimensions:    (index: 4)
        Coordinates:
          * index      (index) int64 32B 0 1 2 3
        Data variables:
            name       (index) object 32B 'falcon' 'parrot' 'lion' 'monkey'
            class      (index) object 32B 'bird' 'bird' 'mammal' 'mammal'
            max_speed  (index) float64 32B 389.0 24.0 80.5 nan
            num_legs   (index) int64 32B 2 2 4 4

        >>> df['max_speed'].to_xarray()  # doctest: +SKIP
        <xarray.DataArray 'max_speed' (index: 4)>
        array([389. ,  24. ,  80.5,   nan])
        Coordinates:
          * index    (index) int64 0 1 2 3

        >>> dates = pd.to_datetime(['2018-01-01', '2018-01-01',
        ...                         '2018-01-02', '2018-01-02'])
        >>> df_multiindex = pd.DataFrame({'date': dates,
        ...                               'animal': ['falcon', 'parrot',
        ...                                          'falcon', 'parrot'],
        ...                               'speed': [350, 18, 361, 15]})
        >>> df_multiindex = df_multiindex.set_index(['date', 'animal'])

        >>> df_multiindex
                           speed
        date       animal
        2018-01-01 falcon    350
                   parrot     18
        2018-01-02 falcon    361
                   parrot     15

        >>> df_multiindex.to_xarray()  # doctest: +SKIP
        <xarray.Dataset>
        Dimensions:  (date: 2, animal: 2)
        Coordinates:
          * date     (date) datetime64[ns] 2018-01-01 2018-01-02
          * animal   (animal) object 'falcon' 'parrot'
        Data variables:
            speed    (date, animal) int64 350 18 361 15
        �xarrayr�)rIr�	DataArray�from_series�Dataset�from_dataframe)r�r�s  r��	to_xarrayzNDFrame.to_xarray�sF��Z,�H�5���9�9��>��#�#�/�/��5�5��>�>�0�0��6�6r��bufc��yr�rt�r�r�rrKrrI�
formattersrL�sparsify�index_names�	bold_rows�
column_format�	longtable�escaperw�decimal�multicolumn�multicolumn_format�multirow�captionr��positions                      r�r5zNDFrame.to_latex
���2	r�c��yr�rtr�s                      r�r5zNDFrame.to_latex 
r�r�r5c����&�|jdk(r|j�}|�tjd�dk(}|
�tjd�dk(}
|�tjd�}|�tjd�}|�tjd	�}|�t	|t
�st
d
��|�t|j�n
t|�}t	|ttf�r)t|�|k7rt
d|�dt|��d
���||
rdnd|d�}ddi|�}ddi|�}t	�t
�r�fd��&n��&�&fd�}d}t	|t�r7t|j�D��cic]\}}|t|||����}}}n�t	|t�r�|jdd�}|jdd�}|�|jd|i�|�|jd|i�|}|j!d��j} | D](}!|!|j#�vs�|j|!�&i��*n|���t|d���}||g}"g}#g}$|r1|#j%|jD�cgc]	}||vs�|��c}dd��|dur|#j%ddi�n-t	|ttf�r|$j%|dd��|g}"|dur|#j%ddi�|	dur|#j%ddd ��d|||rdnd|r|nd!|��|rd"nd#||||||rt	|j&t(�rd$nd|
d%�
}%|j+||#|$d|i|�|"|%�&�Scc}}wcc}w)'a$
        Render object to a LaTeX tabular, longtable, or nested table.

        Requires ``\usepackage{{booktabs}}``.  The output can be copy/pasted
        into a main LaTeX document or read from an external file
        with ``\input{{table.tex}}``.

        .. versionchanged:: 2.0.0
           Refactored to use the Styler implementation via jinja2 templating.

        Parameters
        ----------
        buf : str, Path or StringIO-like, optional, default None
            Buffer to write to. If None, the output is returned as a string.
        columns : list of label, optional
            The subset of columns to write. Writes all columns by default.
        header : bool or list of str, default True
            Write out the column names. If a list of strings is given,
            it is assumed to be aliases for the column names.
        index : bool, default True
            Write row names (index).
        na_rep : str, default 'NaN'
            Missing data representation.
        formatters : list of functions or dict of {{str: function}}, optional
            Formatter functions to apply to columns' elements by position or
            name. The result of each function must be a unicode string.
            List must be of length equal to the number of columns.
        float_format : one-parameter function or str, optional, default None
            Formatter for floating point numbers. For example
            ``float_format="%.2f"`` and ``float_format="{{:0.2f}}".format`` will
            both result in 0.1234 being formatted as 0.12.
        sparsify : bool, optional
            Set to False for a DataFrame with a hierarchical index to print
            every multiindex key at each row. By default, the value will be
            read from the config module.
        index_names : bool, default True
            Prints the names of the indexes.
        bold_rows : bool, default False
            Make the row labels bold in the output.
        column_format : str, optional
            The columns format as specified in `LaTeX table format
            <https://en.wikibooks.org/wiki/LaTeX/Tables>`__ e.g. 'rcl' for 3
            columns. By default, 'l' will be used for all columns except
            columns of numbers, which default to 'r'.
        longtable : bool, optional
            Use a longtable environment instead of tabular. Requires
            adding a \usepackage{{longtable}} to your LaTeX preamble.
            By default, the value will be read from the pandas config
            module, and set to `True` if the option ``styler.latex.environment`` is
            `"longtable"`.

            .. versionchanged:: 2.0.0
               The pandas option affecting this argument has changed.
        escape : bool, optional
            By default, the value will be read from the pandas config
            module and set to `True` if the option ``styler.format.escape`` is
            `"latex"`. When set to False prevents from escaping latex special
            characters in column names.

            .. versionchanged:: 2.0.0
               The pandas option affecting this argument has changed, as has the
               default value to `False`.
        encoding : str, optional
            A string representing the encoding to use in the output file,
            defaults to 'utf-8'.
        decimal : str, default '.'
            Character recognized as decimal separator, e.g. ',' in Europe.
        multicolumn : bool, default True
            Use \multicolumn to enhance MultiIndex columns.
            The default will be read from the config module, and is set
            as the option ``styler.sparse.columns``.

            .. versionchanged:: 2.0.0
               The pandas option affecting this argument has changed.
        multicolumn_format : str, default 'r'
            The alignment for multicolumns, similar to `column_format`
            The default will be read from the config module, and is set as the option
            ``styler.latex.multicol_align``.

            .. versionchanged:: 2.0.0
               The pandas option affecting this argument has changed, as has the
               default value to "r".
        multirow : bool, default True
            Use \multirow to enhance MultiIndex rows. Requires adding a
            \usepackage{{multirow}} to your LaTeX preamble. Will print
            centered labels (instead of top-aligned) across the contained
            rows, separating groups via clines. The default will be read
            from the pandas config module, and is set as the option
            ``styler.sparse.index``.

            .. versionchanged:: 2.0.0
               The pandas option affecting this argument has changed, as has the
               default value to `True`.
        caption : str or tuple, optional
            Tuple (full_caption, short_caption),
            which results in ``\caption[short_caption]{{full_caption}}``;
            if a single string is passed, no short caption will be set.
        label : str, optional
            The LaTeX label to be placed inside ``\label{{}}`` in the output.
            This is used with ``\ref{{}}`` in the main ``.tex`` file.

        position : str, optional
            The LaTeX positional argument for tables, to be placed after
            ``\begin{{}}`` in the output.

        Returns
        -------
        str or None
            If buf is None, returns the result as a string. Otherwise returns None.

        See Also
        --------
        io.formats.style.Styler.to_latex : Render a DataFrame to LaTeX
            with conditional formatting.
        DataFrame.to_string : Render a DataFrame to a console-friendly
            tabular output.
        DataFrame.to_html : Render a DataFrame as an HTML table.

        Notes
        -----
        As of v2.0.0 this method has changed to use the Styler implementation as
        part of :meth:`.Styler.to_latex` via ``jinja2`` templating. This means
        that ``jinja2`` is a requirement, and needs to be installed, for this method
        to function. It is advised that users switch to using Styler, since that
        implementation is more frequently updated and contains much more
        flexibility with the output.

        Examples
        --------
        Convert a general DataFrame to LaTeX with formatting:

        >>> df = pd.DataFrame(dict(name=['Raphael', 'Donatello'],
        ...                        age=[26, 45],
        ...                        height=[181.23, 177.65]))
        >>> print(df.to_latex(index=False,
        ...                   formatters={"name": str.upper},
        ...                   float_format="{:.1f}".format,
        ... ))  # doctest: +SKIP
        \begin{tabular}{lrr}
        \toprule
        name & age & height \\
        \midrule
        RAPHAEL & 26 & 181.2 \\
        DONATELLO & 45 & 177.7 \\
        \bottomrule
        \end{tabular}
        r�Nzstyler.latex.environmentr�zstyler.format.escaper3zstyler.sparse.columnszstyler.latex.multicol_alignzstyler.sparse.indexz&`column_format` must be str or unicodezWriting z cols but got z aliases)rIr�r�r�rc����|zSr�rt)�xrLs �r��<lambda>z"NDFrame.to_latex.<locals>.<lambda>s
���|�a�7Gr�c�T��t|ttf�r
���|�S||�Sr�)r��float�complex)r��alt_format_�
float_format_s  �r��_wrapzNDFrame.to_latex.<locals>._wraps,����!�e�W�-�.�=�3L�$�Q�'�'�"�1�~�%r�)r��	__index__�__columns__rYr�)�includec��|Sr�rt�r5s r�r�z"NDFrame.to_latex.<locals>.<lambda>&s��qr�r)�subsetr�F)rUr�rT)r"r�znaive-�t�naivezskip-last;data)
�hrules�sparse_index�sparse_columns�environment�multicol_align�multirow_alignrwr�r�r�r��clinesr���hide�
relabel_indexrr�format_index�
render_kwargs)rrVrr4r�r�rr�rr%rJr!rr�rwr�
select_dtypesr�rqrr�_to_latex_via_styler)'r�r�rrKrrIr�rLr�r�r�r�r�r�rwr�r�r�r�r�r�r��length�base_format_�
index_format_�column_format_r��formatters_r'�c�index_formatter�column_formatter�
float_columns�col�
format_index_�hide_�relabel_index_�render_kwargs_r�s'       `                              @r�r5zNDFrame.to_latex;
s����`�9�9��>��=�=�?�D����)�)�*D�E��T�I��>��&�&�'=�>�'�I�F��� �+�+�,C�D�K��%�!'�!2�!2�3P�!Q�����(�(�)>�?�H��$�Z�
�s�-K��E�F�F�&-�o��T�\�\�"�3�w�<���f�t�U�m�,��V���1F��x��x�~�c�&�k�]�(�S�T�T��!'�g�T��
��
*0��(C�l�(C�
�*0�!�)D�|�)D���l�C�(�-G�M�(�M�	&�>B���j�$�'�&�d�l�l�3��3�D�A�q��7�5�j��m�<�<�3�
���
�D�
)�(�n�n�[�$�?�O�)�~�~�m�T�B���*��$�$�k�?�%C�D��+��%�%�{�4D�&E�F�$�K� �.�.�w�.�?�G�G�M�$���j�o�o�/�/��&�&��]�';�<�%��
�L�$<�!�%�[�A�K�&��7�
���%'����L�L�*.�,�,�K�,�Q�!�7�:J�q�,�K�%��
��U�?��L�L�&�)�,�-�
���u�
�
.��!�!�V�Y�"G�H�*�O�M��E�>��L�L�&�'�*�+��%���L�L�4��9�:��$�&�*3�;���1��,�-�.�%-�c�7� ��� �*��Z��
�
�J�?�'��"�#
��(�(�(���(���=��=�&�(�
)�
�	
��}��6Ls�6M�4	M�>Mr�c�v�ddlm}td|�}||d��}dD]\}	t�|	}
t	|
t
�rt
||	�d
i|
���3t	|
t�s�D|
D]}t
||	�d
i|����^|�in|}|jd�r|jd��|jd
d	|i|��S)a"
        Render object to a LaTeX tabular, longtable, or nested table.

        Uses the ``Styler`` implementation with the following, ordered, method chaining:

        .. code-block:: python
           styler = Styler(DataFrame)
           styler.hide(**hide)
           styler.relabel_index(**relabel_index)
           styler.format(**format)
           styler.format_index(**format_index)
           styler.to_latex(buf=buf, **render_kwargs)

        Parameters
        ----------
        buf : str, Path or StringIO-like, optional, default None
            Buffer to write to. If None, the output is returned as a string.
        hide : dict, list of dict
            Keyword args to pass to the method call of ``Styler.hide``. If a list will
            call the method numerous times.
        relabel_index : dict, list of dict
            Keyword args to pass to the method of ``Styler.relabel_index``. If a list
            will call the method numerous times.
        format : dict, list of dict
            Keyword args to pass to the method call of ``Styler.format``. If a list will
            call the method numerous times.
        format_index : dict, list of dict
            Keyword args to pass to the method call of ``Styler.format_index``. If a
            list will call the method numerous times.
        render_kwargs : dict
            Keyword args to pass to the method call of ``Styler.to_latex``.

        Returns
        -------
        str or None
            If buf is None, returns the result as a string. Otherwise returns None.
        r)�Stylerr�r�)�uuid)r�r�rrr�r�c��y)Nztextbf:--rwrap;rtr�s r�r�z.NDFrame._to_latex_via_styler.<locals>.<lambda>�s��'8r�r�rt)�pandas.io.formats.styler�r
�varsr�r�r r%rw�	map_indexr5)r�r�r�r�rrr�r�r��styler�kw_name�kw�sub_kws            r�r�zNDFrame._to_latex_via_styler[s���`	3��K��&����2�&��J�G�����B��"�d�#�(����(�.�2�.��B��%� �F�,�G�F�G�,�6�v�6�!�K�,�3���
����[�)����8�9��v���8�3�8�-�8�8r�c��yr�rt�r�rZr�rIrLrrKrrMrirwrg�quoting�	quotechar�lineterminatorr~ra�doublequote�
escapecharr�r~rEs                      r��to_csvzNDFrame.to_csv�r�r�c��yr�rtr�s                      r�r�zNDFrame.to_csv�r�r�r�c��t|t�r|n|j�}t||||||��}t	|�j||||
||||||	||
||||��S)a�
        Write object to a comma-separated values (csv) file.

        Parameters
        ----------
        path_or_buf : str, path object, file-like object, or None, default None
            String, path object (implementing os.PathLike[str]), or file-like
            object implementing a write() function. If None, the result is
            returned as a string. If a non-binary file object is passed, it should
            be opened with `newline=''`, disabling universal newlines. If a binary
            file object is passed, `mode` might need to contain a `'b'`.
        sep : str, default ','
            String of length 1. Field delimiter for the output file.
        na_rep : str, default ''
            Missing data representation.
        float_format : str, Callable, default None
            Format string for floating point numbers. If a Callable is given, it takes
            precedence over other numeric formatting parameters, like decimal.
        columns : sequence, optional
            Columns to write.
        header : bool or list of str, default True
            Write out the column names. If a list of strings is given it is
            assumed to be aliases for the column names.
        index : bool, default True
            Write row names (index).
        index_label : str or sequence, or False, default None
            Column label for index column(s) if desired. If None is given, and
            `header` and `index` are True, then the index names are used. A
            sequence should be given if the object uses MultiIndex. If
            False do not print fields for index names. Use index_label=False
            for easier importing in R.
        mode : {{'w', 'x', 'a'}}, default 'w'
            Forwarded to either `open(mode=)` or `fsspec.open(mode=)` to control
            the file opening. Typical values include:

            - 'w', truncate the file first.
            - 'x', exclusive creation, failing if the file already exists.
            - 'a', append to the end of file if it exists.

        encoding : str, optional
            A string representing the encoding to use in the output file,
            defaults to 'utf-8'. `encoding` is not supported if `path_or_buf`
            is a non-binary file object.
        {compression_options}

               May be a dict with key 'method' as compression mode
               and other entries as additional compression options if
               compression mode is 'zip'.

               Passing compression options as keys in dict is
               supported for compression modes 'gzip', 'bz2', 'zstd', and 'zip'.
        quoting : optional constant from csv module
            Defaults to csv.QUOTE_MINIMAL. If you have set a `float_format`
            then floats are converted to strings and thus csv.QUOTE_NONNUMERIC
            will treat them as non-numeric.
        quotechar : str, default '\"'
            String of length 1. Character used to quote fields.
        lineterminator : str, optional
            The newline character or character sequence to use in the output
            file. Defaults to `os.linesep`, which depends on the OS in which
            this method is called ('\\n' for linux, '\\r\\n' for Windows, i.e.).

            .. versionchanged:: 1.5.0

                Previously was line_terminator, changed for consistency with
                read_csv and the standard library 'csv' module.

        chunksize : int or None
            Rows to write at a time.
        date_format : str, default None
            Format string for datetime objects.
        doublequote : bool, default True
            Control quoting of `quotechar` inside a field.
        escapechar : str, default None
            String of length 1. Character used to escape `sep` and `quotechar`
            when appropriate.
        decimal : str, default '.'
            Character recognized as decimal separator. E.g. use ',' for
            European data.
        errors : str, default 'strict'
            Specifies how encoding and decoding errors are to be handled.
            See the errors argument for :func:`open` for a full list
            of options.

        {storage_options}

        Returns
        -------
        None or str
            If path_or_buf is None, returns the resulting csv format as a
            string. Otherwise returns None.

        See Also
        --------
        read_csv : Load a CSV file into a DataFrame.
        to_excel : Write DataFrame to an Excel file.

        Examples
        --------
        Create 'out.csv' containing 'df' without indices

        >>> df = pd.DataFrame({{'name': ['Raphael', 'Donatello'],
        ...                    'mask': ['red', 'purple'],
        ...                    'weapon': ['sai', 'bo staff']}})
        >>> df.to_csv('out.csv', index=False)  # doctest: +SKIP

        Create 'out.zip' containing 'out.csv'

        >>> df.to_csv(index=False)
        'name,mask,weapon\nRaphael,red,sai\nDonatello,purple,bo staff\n'
        >>> compression_opts = dict(method='zip',
        ...                         archive_name='out.csv')  # doctest: +SKIP
        >>> df.to_csv('out.zip', index=False,
        ...           compression=compression_opts)  # doctest: +SKIP

        To write a csv file to a new folder or nested folder you will first
        need to create it using either Pathlib or os:

        >>> from pathlib import Path  # doctest: +SKIP
        >>> filepath = Path('folder/subfolder/out.csv')  # doctest: +SKIP
        >>> filepath.parent.mkdir(parents=True, exist_ok=True)  # doctest: +SKIP
        >>> df.to_csv(filepath)  # doctest: +SKIP

        >>> import os  # doctest: +SKIP
        >>> os.makedirs('folder/subfolder', exist_ok=True)  # doctest: +SKIP
        >>> df.to_csv('folder/subfolder/out.csv')  # doctest: +SKIP
        )�framerKrrIrLr�)r�r�rwr~rgr�rrMrir~r�rar�r�rE)r�rkrVr�r�r�)r�rZr�rIrLrrKrrMrirwrgr�r�r�r~rar�r�r�r~rEr�rYs                        r�r�zNDFrame.to_csv�s���~ ��l�3�T������&�����%��

�	�!��+�2�2��)����#���#����#�#�!�+�!3�
�	
r�c��t|��)z#
        Reset the cacher.
        r�r�s r��
_reset_cacherzNDFrame._reset_cacher�s��"�$�'�'r�c�h�t�ry|r|jd��|r|j�yy)a!
        See if we need to update our parent cacher if clear, then clear our
        cache.

        Parameters
        ----------
        clear : bool, default False
            Clear the item cache.
        verify_is_copy : bool, default True
            Provide is_copy checks.
        N�referent�r�)r�_check_setitem_copyr[)r��clear�verify_is_copyr�s    r��_maybe_update_cacherzNDFrame._maybe_update_cacher�s5��"� ����$�$�z�$�2���"�"�$�r�c��t|��r�r�r�s r�r[zNDFrame._clear_item_cache��
��!�$�'�'r�c�8�tjd|�t|t�sjt	j
|tj��}|dk(r�|jdk(r�t�r�t|t|��r�|jd��S|jdk(r!tt|�j�d���tj dt|�j�d	�t"t%��
�t	j&|j(|j*|j,tj��}|j.j1||j3|�d��}|j5||j6�
�j9|d��S)a�

        Return the elements in the given *positional* indices along an axis.

        This means that we are not indexing according to actual values in
        the index attribute of the object. We are indexing according to the
        actual position of the element in the object.

        Parameters
        ----------
        indices : array-like
            An array of ints indicating which positions to take.
        axis : {0 or 'index', 1 or 'columns', None}, default 0
            The axis on which to select elements. ``0`` means that we are
            selecting rows, ``1`` means that we are selecting columns.
            For `Series` this parameter is unused and defaults to 0.
        **kwargs
            For compatibility with :meth:`numpy.take`. Has no effect on the
            output.

        Returns
        -------
        same type as caller
            An array-like containing the elements taken from the object.

        See Also
        --------
        DataFrame.loc : Select a subset of a DataFrame by labels.
        DataFrame.iloc : Select a subset of a DataFrame by positions.
        numpy.take : Take elements from an array along an axis.

        Examples
        --------
        >>> df = pd.DataFrame([('falcon', 'bird', 389.0),
        ...                    ('parrot', 'bird', 24.0),
        ...                    ('lion', 'mammal', 80.5),
        ...                    ('monkey', 'mammal', np.nan)],
        ...                   columns=['name', 'class', 'max_speed'],
        ...                   index=[0, 2, 3, 1])
        >>> df
             name   class  max_speed
        0  falcon    bird      389.0
        2  parrot    bird       24.0
        3    lion  mammal       80.5
        1  monkey  mammal        NaN

        Take elements at positions 0 and 3 along the axis 0 (default).

        Note how the actual indices selected (0 and 1) do not correspond to
        our selected indices 0 and 3. That's because we are selecting the 0th
        and 3rd rows, not rows whose indices equal 0 and 3.

        >>> df.take([0, 3])
             name   class  max_speed
        0  falcon    bird      389.0
        1  monkey  mammal        NaN

        Take elements at indices 1 and 2 along the axis 1 (column selection).

        >>> df.take([1, 2], axis=1)
            class  max_speed
        0    bird      389.0
        2    bird       24.0
        3  mammal       80.5
        1  mammal        NaN

        We may take elements using negative integers for positive indices,
        starting from the end of the object, just like with Python lists.

        >>> df.take([-1, -2])
             name   class  max_speed
        1  monkey  mammal        NaN
        3    lion  mammal       80.5
        rtr�rr�Nr�z1.take requires a sequence of integers, not slice.zPassing a slice to zq.take is deprecated and will raise in a future version. Use `obj[slicer]` or pass a sequence of integers instead.r�T�r��verifyr��takera)�nv�
validate_taker�rzrOr�intprrrr�r�r�rr�r�r�rcrU�arange�start�stop�stepr�r�r�r�r�r�)r��indicesr�rr�s     r�r�zNDFrame.take�s\��X	����V�$��'�5�)��j�j�����8�G���	��L�L�A�%�'�)�$�W�c�$�i�8��y�y�d�y�+�+�
�Y�Y�!�^����:�&�&�'�(���
�

�M�M�%�d�4�j�&9�&9�%:�;2�2��+�-�

��i�i��
�
�w�|�|�W�\�\�����G��9�9�>�>���-�-�d�3��"�
��
�)�)�(����)�G�T�T���U�
�	
r�c���|j||��}|jdk(r@|j|�j|j|��s|j	|�|S)ag
        Internal version of the `take` method that sets the `_is_copy`
        attribute to keep track of the parent dataframe (using in indexing
        for the SettingWithCopyWarning).

        For Series this does the same as the public take (it never sets `_is_copy`).

        See the docstring of `take` for full explanation of the parameters.
        )r�r�r)r�rr
r��_set_is_copy)r�r�r�rvs    r��_take_with_is_copyzNDFrame._take_with_is_copy.sU�����7���6���9�9��>�&�"2�"2�4�"8�"?�"?����t�@T�"U�����%��
r�c��|j|�}|j|�}t|t�rt	d��|��t|t
�st	d��|j
|||��\}}td�g|jz}|||<t|�}	|j|	}
t|
|
j|�|�|
S|dk(r|r||S|j}n|j}t|t
�r<|j|d��\}}|s�t!j"|�r	|||dz}n�||}n�|j%|�}t|t&j(�rU|j*t&j,k(r%|j/�\}
|j1|
|��S|j1||��St3|�s||}t3|�r�|dk(r||jdk(r|j4|S|j6j9|�}|j;||j<�	�}
|j||
_|
jA|�}
n[t3|�r!|jdd�t||dz�f}
n/|dk(r|jdd�|f}
n|j|}
|
_|
jC||
jD�
�|
S)aQ

        Return cross-section from the Series/DataFrame.

        This method takes a `key` argument to select data at a particular
        level of a MultiIndex.

        Parameters
        ----------
        key : label or tuple of label
            Label contained in the index, or partially in a MultiIndex.
        axis : {0 or 'index', 1 or 'columns'}, default 0
            Axis to retrieve cross-section on.
        level : object, defaults to first n levels (n=1 or len(key))
            In case of a key partially contained in a MultiIndex, indicate
            which levels are used. Levels can be referred by label or position.
        drop_level : bool, default True
            If False, returns object with same levels as self.

        Returns
        -------
        Series or DataFrame
            Cross-section from the original Series or DataFrame
            corresponding to the selected index levels.

        See Also
        --------
        DataFrame.loc : Access a group of rows and columns
            by label(s) or a boolean array.
        DataFrame.iloc : Purely integer-location based indexing
            for selection by position.

        Notes
        -----
        `xs` can not be used to set values.

        MultiIndex Slicers is a generic way to get/set values on
        any level or levels.
        It is a superset of `xs` functionality, see
        :ref:`MultiIndex Slicers <advanced.mi_slicers>`.

        Examples
        --------
        >>> d = {'num_legs': [4, 4, 2, 2],
        ...      'num_wings': [0, 0, 2, 2],
        ...      'class': ['mammal', 'mammal', 'mammal', 'bird'],
        ...      'animal': ['cat', 'dog', 'bat', 'penguin'],
        ...      'locomotion': ['walks', 'walks', 'flies', 'walks']}
        >>> df = pd.DataFrame(data=d)
        >>> df = df.set_index(['class', 'animal', 'locomotion'])
        >>> df
                                   num_legs  num_wings
        class  animal  locomotion
        mammal cat     walks              4          0
               dog     walks              4          0
               bat     flies              2          2
        bird   penguin walks              2          2

        Get values at specified index

        >>> df.xs('mammal')
                           num_legs  num_wings
        animal locomotion
        cat    walks              4          0
        dog    walks              4          0
        bat    flies              2          2

        Get values at several indexes

        >>> df.xs(('mammal', 'dog', 'walks'))
        num_legs     4
        num_wings    0
        Name: (mammal, dog, walks), dtype: int64

        Get values at specified index and level

        >>> df.xs('cat', level=1)
                           num_legs  num_wings
        class  locomotion
        mammal walks              4          0

        Get values at several indexes and levels

        >>> df.xs(('bird', 'walks'),
        ...       level=[0, 'locomotion'])
                 num_legs  num_wings
        animal
        penguin         2          2

        Get values at specified column and axis

        >>> df.xs('num_wings', axis=1)
        class   animal   locomotion
        mammal  cat      walks         0
                dog      walks         0
                bat      flies         2
        bird    penguin  walks         2
        Name: num_wings, dtype: int64
        z7list keys are not supported in xs, pass a tuple insteadNzIndex must be a MultiIndex)r*�
drop_levelr�rr�r�r��r�)#rr
r�r%r�r�
get_loc_levelrzrrJr|rYrrr�_get_loc_levelr�
is_integer�get_locrO�ndarrayr�r��nonzeror�rgrfr��fast_xs�_constructor_sliced_from_mgrr�r�r�r��_is_view)r�r)r�r*rrU�loc�new_ax�_indexerr�rvrr��indsr�s               r�r�z
NDFrame.xs?s���T�$�$�T�*������%���c�4� ��U�V�V����f�j�1�� <�=�=� �.�.�s�%�J�.�W�K�C���d��}�t�y�y�0�H� �H�T�N��H�o�G��Y�Y�w�'�F��F�F�1�1�$�7��@��M��1�9���C�y� ��L�L�E��J�J�E��e�Z�(�"�1�1�#�Q�1�?�N�C����>�>�#�&� %�c�C�!�G� 4�I� %�c�
�I��-�-��$�C��#�r�z�z�*��9�9����(�!�k�k�m�G�T��2�2�4�d�2�C�C��2�2�3�T�2�B�B��S�>�!�#�J�	��S�>�d�a�i��y�y�A�~��|�|�C�(�(��i�i�'�'��,�G��6�6�w�W�\�\�6�R�F��:�:�c�?�F�L��(�(��.�F�
�s�^��Y�Y�q�%��S�1�W�"5�5�6�F�
�Q�Y��Y�Y�q�#�v�&�F��Y�Y�s�^�F�$�F�L�	���D�6�?�?�':��;��
r�c��t|��r�r�)r�rus  r��__getitem__zNDFrame.__getitem__�r�r�c�l�|jj|d��}t|tj�rmtj|jtjd��t|��}t|tj�r|j|d��S|}|j|�S)zK
        __getitem__ for the case where the key is a slice object.
        �getitem)r�Frrr�)r�_convert_slice_indexerr�rOrr�maybe_indices_to_slicer�r�r�r��_slice)r�r)�slobjr�s    r��_getitem_slicezNDFrame._getitem_slice�s����
�
�1�1�#�I�1�F���e�R�Z�Z�(��0�0����R�W�W�5��1�3�t�9��G��'�2�:�:�.��y�y��q�y�1�1��E��{�{�5�!�!r�c�J�t|t�sJt|���|j|�}|jj||��}|j
||j��}|j|�}|dk7xs|j}|j||��|S)zp
        Construct a slice of this container.

        Slicing with this method is *always* positional.
        r�r�rr)r�rzrr�r��	get_slicer�r�r�rr�)r�rr�r�rv�is_copys      r�rzNDFrame._slice	s����%��'�4��e��4�'��+�+�D�1���)�)�%�%�e�$�%�7���+�+�G�'�,�,�+�G���$�$�T�*���!�)�.�v�������D�w��/��
r�c�T�|sd|_y|�J�tj|�|_yr�)r��weakref�ref)r�rr�s   r�r�zNDFrame._set_is_copys&��� �D�M��?�"�?�#�K�K��,�D�Mr�c�@�|jr|jd��y)aV
        Check if we are a view, have a cacher, and are of mixed type.
        If so, then force a setitem_copy check.

        Should be called just near setting a value

        Will return a boolean if it we are a view and are cached, but a
        single-dtype meaning that the cacher should be updated following
        setting.
        r�r�F)r�r�r�s r��%_check_is_chained_assignment_possiblez-NDFrame._check_is_chained_assignment_possible#s���=�=��$�$�z�$�2�r�c�.�t�s
t�ry|s
|jsytjd�}|�y|j�bt|jt�sH|j�}tj|�r|�!|j|jk(rd|_yt|jt�r
|j}n
|dk(rd}nd}|dk(rt|��|dk(r%tj|tt���yy)	a

        Parameters
        ----------
        t : str, the type of setting error
        force : bool, default False
           If True, then force showing an error.

        validate if we are doing a setitem on a chained copy.

        It is technically possible to figure out that we are setting on
        a copy even WITH a multi-dtyped pandas object. In other words, some
        blocks may be views while other are not. Currently _is_view will ALWAYS
        return False for multi-blocks to avoid having to handle this case.

        df = DataFrame(np.arange(0,9), columns=['count'])
        df['group'] = 'b'

        # This technically need not raise SettingWithCopy if both are view
        # (which is not generally guaranteed but is usually True.  However,
        # this is in general not a good practice and we recommend using .loc.
        df.iloc[0:5]['group'] = 'a'

        Nzmode.chained_assignmentr�z�
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copya
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copyr�r�r�)rrr�rr4r�r��gc�
get_referentsrKrNr�r�rOrU)r�r��forcer��rs     r�r�zNDFrame._check_setitem_copy2s���4� �$6�$8��������!�!�";�<���=���=�=�$�Z��
�
�s�-K��
�
��A��#�#�A�&�1�=�Q�W�W��
�
�=R� $��
���d�m�m�S�)��
�
�A�
�*�_�?�
�?�
��G��&�q�)�)��F�?��M�M�!�3�@P�@R�S�r�c��d}d}|jdk(r3t|jt�r	||jjv}|rLt|t�s|f}|jD]*}t|t�s�|dt|�|k(s�&||=d}�,|s>|jdj|�}|jj|�|_
	|j|=y#t
$rY��wxYw#t$rYywxYw)z
        Delete item
        FrNTr�)rr�rr�_enginer�rJr�r�rr��ideleter�r)r�r)�deleted�maybe_shortcutr�rs      r��__delitem__zNDFrame.__delitem__}s���
�����9�9��>�j����z�B�
�"%�D�L�L�,@�,@�!@����c�5�)��f���|�|���c�5�)�c�*�C��H�o��.D��S�	�"�G�$���)�)�B�-�'�'��,�C��	�	�)�)�#�.�D�I�	�� � ��%��+�
��
��,�	��	�s#�C$�
C3�$	C0�/C0�3	C?�>C?c�L�|r"|jjstd��yy)NzQCannot specify 'inplace=True' when 'self.flags.allows_duplicate_labels' is False.)r�r�r)r�r�s  r�r�z2NDFrame._check_inplace_and_allows_duplicate_labels�s+���4�:�:�=�=��A��
�>�7r�c�F�	||S#tttf$r|cYSwxYw)aB
        Get item from object for given key (ex: DataFrame column).

        Returns default value if not found.

        Parameters
        ----------
        key : object

        Returns
        -------
        same type as items contained in object

        Examples
        --------
        >>> df = pd.DataFrame(
        ...     [
        ...         [24.3, 75.7, "high"],
        ...         [31, 87.8, "high"],
        ...         [22, 71.6, "medium"],
        ...         [35, 95, "medium"],
        ...     ],
        ...     columns=["temp_celsius", "temp_fahrenheit", "windspeed"],
        ...     index=pd.date_range(start="2014-02-12", end="2014-02-15", freq="D"),
        ... )

        >>> df
                    temp_celsius  temp_fahrenheit windspeed
        2014-02-12          24.3             75.7      high
        2014-02-13          31.0             87.8      high
        2014-02-14          22.0             71.6    medium
        2014-02-15          35.0             95.0    medium

        >>> df.get(["temp_celsius", "windspeed"])
                    temp_celsius windspeed
        2014-02-12          24.3      high
        2014-02-13          31.0      high
        2014-02-14          22.0    medium
        2014-02-15          35.0    medium

        >>> ser = df['windspeed']
        >>> ser.get('2014-02-13')
        'high'

        If the key isn't found, the default value will be used.

        >>> df.get(["temp_celsius", "temp_kelvin"], default="default_value")
        'default_value'

        >>> ser.get('2014-02-10', '[unknown]')
        '[unknown]'
        )rr�
IndexError)r�r)�defaults   r�rezNDFrame.get�s-��l	���9����*�j�1�	��N�	�s�� � c�.�|jjS)z:Return boolean indicating if self is view of another array)r��is_viewr�s r�rzNDFrame._is_view�s���y�y� � � r�c�f�|j|j||||��}|jdi|��S)a�
        Return an object with matching indices as other object.

        Conform the object to the same index on all axes. Optional
        filling logic, placing NaN in locations having no value
        in the previous index. A new object is produced unless the
        new index is equivalent to the current one and copy=False.

        Parameters
        ----------
        other : Object of the same data type
            Its row and column indices are used to define the new indices
            of this object.
        method : {None, 'backfill'/'bfill', 'pad'/'ffill', 'nearest'}
            Method to use for filling holes in reindexed DataFrame.
            Please note: this is only applicable to DataFrames/Series with a
            monotonically increasing/decreasing index.

            * None (default): don't fill gaps
            * pad / ffill: propagate last valid observation forward to next
              valid
            * backfill / bfill: use next valid observation to fill gap
            * nearest: use nearest valid observations to fill gap.

        copy : bool, default True
            Return a new object, even if the passed indexes are the same.

            .. note::
                The `copy` keyword will change behavior in pandas 3.0.
                `Copy-on-Write
                <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
                will be enabled by default, which means that all methods with a
                `copy` keyword will use a lazy copy mechanism to defer the copy and
                ignore the `copy` keyword. The `copy` keyword will be removed in a
                future version of pandas.

                You can already get the future behavior and improvements through
                enabling copy on write ``pd.options.mode.copy_on_write = True``
        limit : int, default None
            Maximum number of consecutive labels to fill for inexact matches.
        tolerance : optional
            Maximum distance between original and new labels for inexact
            matches. The values of the index at the matching locations must
            satisfy the equation ``abs(index[indexer] - target) <= tolerance``.

            Tolerance may be a scalar value, which applies the same tolerance
            to all values, or list-like, which applies variable tolerance per
            element. List-like includes list, tuple, array, Series, and must be
            the same size as the index and its dtype must exactly match the
            index's type.

        Returns
        -------
        Series or DataFrame
            Same type as caller, but with changed indices on each axis.

        See Also
        --------
        DataFrame.set_index : Set row labels.
        DataFrame.reset_index : Remove row labels or move them to new columns.
        DataFrame.reindex : Change to new indices or expand indices.

        Notes
        -----
        Same as calling
        ``.reindex(index=other.index, columns=other.columns,...)``.

        Examples
        --------
        >>> df1 = pd.DataFrame([[24.3, 75.7, 'high'],
        ...                     [31, 87.8, 'high'],
        ...                     [22, 71.6, 'medium'],
        ...                     [35, 95, 'medium']],
        ...                    columns=['temp_celsius', 'temp_fahrenheit',
        ...                             'windspeed'],
        ...                    index=pd.date_range(start='2014-02-12',
        ...                                        end='2014-02-15', freq='D'))

        >>> df1
                    temp_celsius  temp_fahrenheit windspeed
        2014-02-12          24.3             75.7      high
        2014-02-13          31.0             87.8      high
        2014-02-14          22.0             71.6    medium
        2014-02-15          35.0             95.0    medium

        >>> df2 = pd.DataFrame([[28, 'low'],
        ...                     [30, 'low'],
        ...                     [35.1, 'medium']],
        ...                    columns=['temp_celsius', 'windspeed'],
        ...                    index=pd.DatetimeIndex(['2014-02-12', '2014-02-13',
        ...                                            '2014-02-15']))

        >>> df2
                    temp_celsius windspeed
        2014-02-12          28.0       low
        2014-02-13          30.0       low
        2014-02-15          35.1    medium

        >>> df2.reindex_like(df1)
                    temp_celsius  temp_fahrenheit windspeed
        2014-02-12          28.0              NaN       low
        2014-02-13          30.0              NaN       low
        2014-02-14           NaN              NaN       NaN
        2014-02-15          35.1              NaN    medium
        )r�rbr��limit�	tolerancert)rr�reindex)r�r�rbr�r3r4rs       r��reindex_likezNDFrame.reindex_like�sE��d
�&�&��"�"�����
'�
���t�|�|� �a� � r�)r�rrr*r~c��yr�rt�r�rUr�rrr*r�r~s        r�r�zNDFrame.dropk���	r�)r�rrr*r�r~c��yr�rtr8s        r�r�zNDFrame.dropyr9r�c��yr�rtr8s        r�r�zNDFrame.drop�r9r�r�c�H�t|d�}|�%|�|�td��|j|�}||i}	n(|�|�d|i}	|jdk(r||	d<ntd��|}
|	j	�D]\}}|��	|
j||||��}
�|r|j
|
�y|
S)Nr�z2Cannot specify both 'labels' and 'index'/'columns'rrrz>Need to specify at least one of 'labels', 'index' or 'columns'�r*r~)rXrrrr��
_drop_axisr�)r�rUr�rrr*r�r~r3r�r�s           r�r�zNDFrame.drop�s���&�g�y�9����� �G�$7� �!U�V�V��+�+�D�1�I��v�&�D�
�
�'�"5��U�#�D��y�y�A�~�")��Y���P��
��� �J�J�L�L�D�&��!��n�n�V�T��v�n�N��)��� � ��%���Jr�c��|j|�}|j|�}|jrX|�0t|t�std��|j
|||��}n|j
||��}|j|�}�n|t|�xst|t�}	ttj|��}|�_t|t�std��|j|�j|�}
|dk(r�|
j�r�t!|�d���t|t�r3|j"dk(r$|	s"|jd�j|�}
nI|j|�}
|j%|�d	k(j'�}|dk(r|rt!|�d���t|
j"t(�r|
j+t,�
�}
|
j/�d}|j1|�}|j2|z
dz
}|j4j7|||dd|�
�}
|j9|
|
j:��}|j2dk(r|j<|_|jA|�S)a
        Drop labels from specified axis. Used in the ``drop`` method
        internally.

        Parameters
        ----------
        labels : single label or list-like
        axis : int or axis name
        level : int or level name, default None
            For MultiIndex
        errors : {'ignore', 'raise'}, default 'raise'
            If 'ignore', suppress error and existing labels are dropped.
        only_slice : bool, default False
            Whether indexing along columns should be view-only.

        Nzaxis must be a MultiIndexr=)r~r�r�r�rr�r�r�T)r��
allow_dupsr��
only_slicer�)!rr
�	is_uniquer�r�AssertionErrorr��get_indexerrnrJr\rs�index_labels_to_arrayr#�isinr�rr�r�r�rj�to_numpyr�rr�rr��reindex_indexerr�r�r(r�r�)r�rUr�r*r~rA�axis_num�new_axisr��is_tuple_labels�mask�labels_missingr�r�rvs               r�r>zNDFrame._drop_axis�sI��2�(�(��.���~�~�d�#���>�>�� �!�$�
�3�(�)D�E�E��9�9�V�5��9�H���9�9�V�F�9�;���&�&�x�0�G�2�&�9�V�Z��PU�=V�O�"�6�#?�#?��#G�H�F�� �!�$�
�3�(�)D�E�E��-�-�e�4�9�9�&�A�A���W�$�����"�f�X�-?�#@�A�A��4��,��L�L�H�,�'�
�-�-�a�0�5�5�f�=�=���	�	�&�)�)��"&�"6�"6�v�">�"�"D�!I�!I�!K���W�$��"�f�X�-?�#@�A�A��$�*�*�n�5��}�}�4�}�0���l�l�n�Q�'�G��y�y��)�H��)�)�h�&��*���)�)�+�+������!�
,�
���+�+�G�'�,�,�+�G���9�9��>��9�9�F�L��"�"�4�(�(r�c��|j�|j�|j|_|j|d��y)z�
        Replace self internals with result.

        Parameters
        ----------
        result : same type as self
        verify_is_copy : bool, default True
            Provide is_copy checks.
        T)r�r�N)�_reset_cacher[r�r�)r�rvr�s   r�r�zNDFrame._update_inplaces:��	
������� ��K�K��	��!�!���!�Nr�c�x���fd�}|j}|�|j|�}||i}|jdi|��S)a6
        Prefix labels with string `prefix`.

        For Series, the row labels are prefixed.
        For DataFrame, the column labels are prefixed.

        Parameters
        ----------
        prefix : str
            The string to add before each label.
        axis : {0 or 'index', 1 or 'columns', None}, default None
            Axis to add prefix on

            .. versionadded:: 2.0.0

        Returns
        -------
        Series or DataFrame
            New Series or DataFrame with updated labels.

        See Also
        --------
        Series.add_suffix: Suffix row labels with string `suffix`.
        DataFrame.add_suffix: Suffix column labels with string `suffix`.

        Examples
        --------
        >>> s = pd.Series([1, 2, 3, 4])
        >>> s
        0    1
        1    2
        2    3
        3    4
        dtype: int64

        >>> s.add_prefix('item_')
        item_0    1
        item_1    2
        item_2    3
        item_3    4
        dtype: int64

        >>> df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]})
        >>> df
           A  B
        0  1  3
        1  2  4
        2  3  5
        3  4  6

        >>> df.add_prefix('col_')
             col_A  col_B
        0       1       3
        1       2       4
        2       3       5
        3       4       6
        c�����|��Sr�rt)r�r&s �r�r�z$NDFrame.add_prefix.<locals>.<lambda>`s
�������nr�rt�r
rr�)r�r&r�r�r3r�s `    r��
add_prefixzNDFrame.add_prefix%sK���v
%���(�(�	����+�+�D�1�I��Q����t�|�|�%�f�%�%r�c�x���fd�}|j}|�|j|�}||i}|jdi|��S)a5
        Suffix labels with string `suffix`.

        For Series, the row labels are suffixed.
        For DataFrame, the column labels are suffixed.

        Parameters
        ----------
        suffix : str
            The string to add after each label.
        axis : {0 or 'index', 1 or 'columns', None}, default None
            Axis to add suffix on

            .. versionadded:: 2.0.0

        Returns
        -------
        Series or DataFrame
            New Series or DataFrame with updated labels.

        See Also
        --------
        Series.add_prefix: Prefix row labels with string `prefix`.
        DataFrame.add_prefix: Prefix column labels with string `prefix`.

        Examples
        --------
        >>> s = pd.Series([1, 2, 3, 4])
        >>> s
        0    1
        1    2
        2    3
        3    4
        dtype: int64

        >>> s.add_suffix('_item')
        0_item    1
        1_item    2
        2_item    3
        3_item    4
        dtype: int64

        >>> df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]})
        >>> df
           A  B
        0  1  3
        1  2  4
        2  3  5
        3  4  6

        >>> df.add_suffix('_col')
             A_col  B_col
        0       1       3
        1       2       4
        2       3       5
        3       4       6
        c���|����Sr�rt)r��suffixs �r�r�z$NDFrame.add_suffix.<locals>.<lambda>�s
�����F�8�nr�rtrR)r�rVr�r�r3r�s `    r��
add_suffixzNDFrame.add_suffixosK���v
%���(�(�	����+�+�D�1�I��Q����t�|�|�%�f�%�%r�)r��	ascendingr�r��na_position�ignore_indexr)c��yr�rt�r�r�rXr�r�rYrZr)s        r��sort_valueszNDFrame.sort_values�r9r�)r�rXr�rYrZr)c��yr�rtr\s        r�r]zNDFrame.sort_values�r9r�c��yr�rtr\s        r�r]zNDFrame.sort_values�r9r��	quicksort�lastc��t|��)uq
        Sort by the values along either axis.

        Parameters
        ----------%(optional_by)s
        axis : %(axes_single_arg)s, default 0
             Axis to be sorted.
        ascending : bool or list of bool, default True
             Sort ascending vs. descending. Specify list for multiple sort
             orders.  If this is a list of bools, must match the length of
             the by.
        inplace : bool, default False
             If True, perform operation in-place.
        kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, default 'quicksort'
             Choice of sorting algorithm. See also :func:`numpy.sort` for more
             information. `mergesort` and `stable` are the only stable algorithms. For
             DataFrames, this option is only applied when sorting on a single
             column or label.
        na_position : {'first', 'last'}, default 'last'
             Puts NaNs at the beginning if `first`; `last` puts NaNs at the
             end.
        ignore_index : bool, default False
             If True, the resulting axis will be labeled 0, 1, …, n - 1.
        key : callable, optional
            Apply the key function to the values
            before sorting. This is similar to the `key` argument in the
            builtin :meth:`sorted` function, with the notable difference that
            this `key` function should be *vectorized*. It should expect a
            ``Series`` and return a Series with the same shape as the input.
            It will be applied to each column in `by` independently.

        Returns
        -------
        DataFrame or None
            DataFrame with sorted values or None if ``inplace=True``.

        See Also
        --------
        DataFrame.sort_index : Sort a DataFrame by the index.
        Series.sort_values : Similar method for a Series.

        Examples
        --------
        >>> df = pd.DataFrame({
        ...     'col1': ['A', 'A', 'B', np.nan, 'D', 'C'],
        ...     'col2': [2, 1, 9, 8, 7, 4],
        ...     'col3': [0, 1, 9, 4, 2, 3],
        ...     'col4': ['a', 'B', 'c', 'D', 'e', 'F']
        ... })
        >>> df
          col1  col2  col3 col4
        0    A     2     0    a
        1    A     1     1    B
        2    B     9     9    c
        3  NaN     8     4    D
        4    D     7     2    e
        5    C     4     3    F

        Sort by col1

        >>> df.sort_values(by=['col1'])
          col1  col2  col3 col4
        0    A     2     0    a
        1    A     1     1    B
        2    B     9     9    c
        5    C     4     3    F
        4    D     7     2    e
        3  NaN     8     4    D

        Sort by multiple columns

        >>> df.sort_values(by=['col1', 'col2'])
          col1  col2  col3 col4
        1    A     1     1    B
        0    A     2     0    a
        2    B     9     9    c
        5    C     4     3    F
        4    D     7     2    e
        3  NaN     8     4    D

        Sort Descending

        >>> df.sort_values(by='col1', ascending=False)
          col1  col2  col3 col4
        4    D     7     2    e
        5    C     4     3    F
        2    B     9     9    c
        0    A     2     0    a
        1    A     1     1    B
        3  NaN     8     4    D

        Putting NAs first

        >>> df.sort_values(by='col1', ascending=False, na_position='first')
          col1  col2  col3 col4
        3  NaN     8     4    D
        4    D     7     2    e
        5    C     4     3    F
        2    B     9     9    c
        0    A     2     0    a
        1    A     1     1    B

        Sorting with a key function

        >>> df.sort_values(by='col4', key=lambda col: col.str.lower())
           col1  col2  col3 col4
        0    A     2     0    a
        1    A     1     1    B
        2    B     9     9    c
        3  NaN     8     4    D
        4    D     7     2    e
        5    C     4     3    F

        Natural sort with the key argument,
        using the `natsort <https://github.com/SethMMorton/natsort>` package.

        >>> df = pd.DataFrame({
        ...    "time": ['0hr', '128hr', '72hr', '48hr', '96hr'],
        ...    "value": [10, 20, 30, 40, 50]
        ... })
        >>> df
            time  value
        0    0hr     10
        1  128hr     20
        2   72hr     30
        3   48hr     40
        4   96hr     50
        >>> from natsort import index_natsorted
        >>> df.sort_values(
        ...     by="time",
        ...     key=lambda x: np.argsort(index_natsorted(df["time"]))
        ... )
            time  value
        0    0hr     10
        3   48hr     40
        2   72hr     30
        4   96hr     50
        1  128hr     20
        r�r\s        r�r]zNDFrame.sort_values�s��l"�$�'�'r�)r�r*rXr�rY�sort_remainingrZr)c	��yr�rt�
r�r�r*rXr�r�rYrcrZr)s
          r��
sort_indexzNDFrame.sort_indexz���	r�)	r�r*rXr�r�rYrcrZr)c	��yr�rtres
          r�rfzNDFrame.sort_index�rgr�c	��yr�rtres
          r�rfzNDFrame.sort_index�rgr�c		�x�t|d�}|j|�}t|�}|j|�}
t	|
||||||	�}|�7|r|}n|jd��}|rt
t|��|_|ry|S|j|�}
|jj||
d��}|s|j|
j�}nt
t|��}|j|
|�|j||j��}|r|j!|�S|j#|d��S)Nr�r�Fr�r�rfra)rXrrWr
r�r�r�r�rr�r�r�r��_sort_levels_monotonicrVr�r�r�)r�r�r*rXr�r�rYrcrZr)�targetr�rv�baxisr�rJs                r�rfzNDFrame.sort_index�s3��&�g�y�9���$�$�T�*��&�y�1�	�����%��%��E�9�d�K���
���?���������-���,�S��Y�7������
��,�,�T�2���9�9�>�>�'��e�>�D����}�}�U�+�B�B�D�H�$�S��\�2�H����%��*��+�+�H�8�=�=�+�I����'�'��/�/��&�&�t�L�&�A�Ar�)r��optional_reindex)	rrr�rbr�r*�
fill_valuer3r4c		����|�|�
|�td��|�|�|�td��|�#|�|}n|}n|r�j|�dk(r|}n|}||d�}t|�}|rt�rd}t	�fd�|j�D��r�j
|��S�j|||�r�j|||�S�j|||	|
|||�j�d�	�S)
av!
        Conform {klass} to new index with optional filling logic.

        Places NA/NaN in locations having no value in the previous index. A new object
        is produced unless the new index is equivalent to the current one and
        ``copy=False``.

        Parameters
        ----------
        {optional_reindex}
        method : {{None, 'backfill'/'bfill', 'pad'/'ffill', 'nearest'}}
            Method to use for filling holes in reindexed DataFrame.
            Please note: this is only applicable to DataFrames/Series with a
            monotonically increasing/decreasing index.

            * None (default): don't fill gaps
            * pad / ffill: Propagate last valid observation forward to next
              valid.
            * backfill / bfill: Use next valid observation to fill gap.
            * nearest: Use nearest valid observations to fill gap.

        copy : bool, default True
            Return a new object, even if the passed indexes are the same.

            .. note::
                The `copy` keyword will change behavior in pandas 3.0.
                `Copy-on-Write
                <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
                will be enabled by default, which means that all methods with a
                `copy` keyword will use a lazy copy mechanism to defer the copy and
                ignore the `copy` keyword. The `copy` keyword will be removed in a
                future version of pandas.

                You can already get the future behavior and improvements through
                enabling copy on write ``pd.options.mode.copy_on_write = True``
        level : int or name
            Broadcast across a level, matching Index values on the
            passed MultiIndex level.
        fill_value : scalar, default np.nan
            Value to use for missing values. Defaults to NaN, but can be any
            "compatible" value.
        limit : int, default None
            Maximum number of consecutive elements to forward or backward fill.
        tolerance : optional
            Maximum distance between original and new labels for inexact
            matches. The values of the index at the matching locations most
            satisfy the equation ``abs(index[indexer] - target) <= tolerance``.

            Tolerance may be a scalar value, which applies the same tolerance
            to all values, or list-like, which applies variable tolerance per
            element. List-like includes list, tuple, array, Series, and must be
            the same size as the index and its dtype must exactly match the
            index's type.

        Returns
        -------
        {klass} with changed index.

        See Also
        --------
        DataFrame.set_index : Set row labels.
        DataFrame.reset_index : Remove row labels or move them to new columns.
        DataFrame.reindex_like : Change to same indices as other DataFrame.

        Examples
        --------
        ``DataFrame.reindex`` supports two calling conventions

        * ``(index=index_labels, columns=column_labels, ...)``
        * ``(labels, axis={{'index', 'columns'}}, ...)``

        We *highly* recommend using keyword arguments to clarify your
        intent.

        Create a dataframe with some fictional data.

        >>> index = ['Firefox', 'Chrome', 'Safari', 'IE10', 'Konqueror']
        >>> df = pd.DataFrame({{'http_status': [200, 200, 404, 404, 301],
        ...                   'response_time': [0.04, 0.02, 0.07, 0.08, 1.0]}},
        ...                   index=index)
        >>> df
                   http_status  response_time
        Firefox            200           0.04
        Chrome             200           0.02
        Safari             404           0.07
        IE10               404           0.08
        Konqueror          301           1.00

        Create a new index and reindex the dataframe. By default
        values in the new index that do not have corresponding
        records in the dataframe are assigned ``NaN``.

        >>> new_index = ['Safari', 'Iceweasel', 'Comodo Dragon', 'IE10',
        ...              'Chrome']
        >>> df.reindex(new_index)
                       http_status  response_time
        Safari               404.0           0.07
        Iceweasel              NaN            NaN
        Comodo Dragon          NaN            NaN
        IE10                 404.0           0.08
        Chrome               200.0           0.02

        We can fill in the missing values by passing a value to
        the keyword ``fill_value``. Because the index is not monotonically
        increasing or decreasing, we cannot use arguments to the keyword
        ``method`` to fill the ``NaN`` values.

        >>> df.reindex(new_index, fill_value=0)
                       http_status  response_time
        Safari                 404           0.07
        Iceweasel                0           0.00
        Comodo Dragon            0           0.00
        IE10                   404           0.08
        Chrome                 200           0.02

        >>> df.reindex(new_index, fill_value='missing')
                      http_status response_time
        Safari                404          0.07
        Iceweasel         missing       missing
        Comodo Dragon     missing       missing
        IE10                  404          0.08
        Chrome                200          0.02

        We can also reindex the columns.

        >>> df.reindex(columns=['http_status', 'user_agent'])
                   http_status  user_agent
        Firefox            200         NaN
        Chrome             200         NaN
        Safari             404         NaN
        IE10               404         NaN
        Konqueror          301         NaN

        Or we can use "axis-style" keyword arguments

        >>> df.reindex(['http_status', 'user_agent'], axis="columns")
                   http_status  user_agent
        Firefox            200         NaN
        Chrome             200         NaN
        Safari             404         NaN
        IE10               404         NaN
        Konqueror          301         NaN

        To further illustrate the filling functionality in
        ``reindex``, we will create a dataframe with a
        monotonically increasing index (for example, a sequence
        of dates).

        >>> date_index = pd.date_range('1/1/2010', periods=6, freq='D')
        >>> df2 = pd.DataFrame({{"prices": [100, 101, np.nan, 100, 89, 88]}},
        ...                    index=date_index)
        >>> df2
                    prices
        2010-01-01   100.0
        2010-01-02   101.0
        2010-01-03     NaN
        2010-01-04   100.0
        2010-01-05    89.0
        2010-01-06    88.0

        Suppose we decide to expand the dataframe to cover a wider
        date range.

        >>> date_index2 = pd.date_range('12/29/2009', periods=10, freq='D')
        >>> df2.reindex(date_index2)
                    prices
        2009-12-29     NaN
        2009-12-30     NaN
        2009-12-31     NaN
        2010-01-01   100.0
        2010-01-02   101.0
        2010-01-03     NaN
        2010-01-04   100.0
        2010-01-05    89.0
        2010-01-06    88.0
        2010-01-07     NaN

        The index entries that did not have a value in the original data frame
        (for example, '2009-12-29') are by default filled with ``NaN``.
        If desired, we can fill in the missing values using one of several
        options.

        For example, to back-propagate the last valid value to fill the ``NaN``
        values, pass ``bfill`` as an argument to the ``method`` keyword.

        >>> df2.reindex(date_index2, method='bfill')
                    prices
        2009-12-29   100.0
        2009-12-30   100.0
        2009-12-31   100.0
        2010-01-01   100.0
        2010-01-02   101.0
        2010-01-03     NaN
        2010-01-04   100.0
        2010-01-05    89.0
        2010-01-06    88.0
        2010-01-07     NaN

        Please note that the ``NaN`` value present in the original dataframe
        (at index value 2010-01-03) will not be filled by any of the
        value propagation schemes. This is because filling while reindexing
        does not look at dataframe values, but only compares the original and
        desired indexes. If you do want to fill in the ``NaN`` values present
        in the original dataframe, use the ``fillna()`` method.

        See the :ref:`user guide <basics.reindexing>` for more.
        z3Cannot specify all of 'labels', 'index', 'columns'.r�r�r�Fc3�h�K�|])\}}|�"�j|�j|����+y�wr�)r
�	identical)rHr3r�r�s   �r�rIz"NDFrame.reindex.<locals>.<genexpr>�s6�����
�!-�
�	�2��~�
�N�N�9�%�/�/��3�!-�s�/2r�r5ra)r�rr�rr�r�r��_needs_reindex_multi�_reindex_multi�
_reindex_axesr�)r�rUrrr�rbr�r*ror3r4r�s`           r�r5zNDFrame.reindex�s,���H���!4��9K��Q�R�R�
�
�'�"5����P����!��$�$�G�"�E���-�-�d�3�q�8� ������8
��+�6�2���'�)��D��
�!%����
�
�
�9�9�$�9�'�'��$�$�T�6�5�9��&�&�t�T�:�>�>��!�!��%��	�6�:�t�
�
�,�t�I�,�
.�	/r�c���|}|jD]`}	||	}
|
��|j|	�}|j|
||||��\}}
|j|	�}|j	|||
gi||d��}d}�b|S)z%Perform the reindex for all the axes.)r*r3r4rbF)ror�r@)rr
r5r�_reindex_with_indexers)r�r�r*r3r4rbror�r�r�rUr�r�r�r�s               r�ruzNDFrame._reindex_axes�s������"�"�A��!�W�F��~������"�B�!#����e�5�I�f�",�"��I�w��(�(��+�D��,�,��	�7�+�,�%�� �	-��C��D�%#�(�
r�c��tj|j��|jk(xr|duxr|duxr|jS)z$Check if we do need a multi reindex.N)rs�count_not_noner�r�_can_fast_transpose)r�r�rbr*s    r�rszNDFrame._needs_reindex_multisN���
"�
"�D�K�K�M�
2�d�n�n�
D�
)��$��
)���
�
)�
�(�(�
	
r�c��t|��r�r�)r�r�r�ros    r�rtzNDFrame._reindex_multir�r�c	��|j}t|j��D]O}||\}}|j|�}	|��t	|�}|�t|�}|j
|||	|||��}d}�Q|s|�+||jurt�s|j|��}n*t�r ||jur|jd��}|j||j��j|�S)z*allow_dups indicates an internal call here)r�ror@r�Fr�r�)r��sortedr�r�r�r]rHrr�r�r�r�)
r��
reindexersror�r@r�r�rr�rms
          r�rwzNDFrame._reindex_with_indexerss	���9�9���:�?�?�,�-�D�'��-�N�E�7��0�0��6�E��}�� ��'�E��"�-�g�6�� �/�/����%�%��
0��H��D�+.�0�T�\��D�I�I�%�'�)��}�}�$�}�/�H�
 �
"�x�4�9�9�'<��}�}�%�}�0�H��)�)�(����)�G�T�T��
�	
r�c�^��
�tj|�|�}|dkDrtd��|�|j}|j	|�}|�h|j|�}t
|�j|�}t|�dk(r|j|j�}|jdi||i��S�r,d	�fd�}|j|�}	|j|��|	S|rAd	�
fd�}tj|��
|j|�}	|j|��|	Std��)
a>
        Subset the dataframe rows or columns according to the specified index labels.

        Note that this routine does not filter a dataframe on its
        contents. The filter is applied to the labels of the index.

        Parameters
        ----------
        items : list-like
            Keep labels from axis which are in items.
        like : str
            Keep labels from axis for which "like in label == True".
        regex : str (regular expression)
            Keep labels from axis for which re.search(regex, label) == True.
        axis : {0 or 'index', 1 or 'columns', None}, default None
            The axis to filter on, expressed either as an index (int)
            or axis name (str). By default this is the info axis, 'columns' for
            DataFrame. For `Series` this parameter is unused and defaults to `None`.

        Returns
        -------
        same type as input object

        See Also
        --------
        DataFrame.loc : Access a group of rows and columns
            by label(s) or a boolean array.

        Notes
        -----
        The ``items``, ``like``, and ``regex`` parameters are
        enforced to be mutually exclusive.

        ``axis`` defaults to the info axis that is used when indexing
        with ``[]``.

        Examples
        --------
        >>> df = pd.DataFrame(np.array(([1, 2, 3], [4, 5, 6])),
        ...                   index=['mouse', 'rabbit'],
        ...                   columns=['one', 'two', 'three'])
        >>> df
                one  two  three
        mouse     1    2      3
        rabbit    4    5      6

        >>> # select columns by name
        >>> df.filter(items=['one', 'three'])
                 one  three
        mouse     1      3
        rabbit    4      6

        >>> # select columns by regular expression
        >>> df.filter(regex='e$', axis=1)
                 one  three
        mouse     1      3
        rabbit    4      6

        >>> # select rows containing 'bbi'
        >>> df.filter(like='bbi', axis=0)
                 one  two  three
        rabbit    4    5      6
        r�zDKeyword arguments `items`, `like`, or `regex` are mutually exclusiverc�&����J��t|�vSr�)r^)r��likes �r�r�zNDFrame.filter.<locals>.f�s����'�'�'��z�!�}�,�,r�r�c�<���jt|��duSr�)�searchr^)r��matchers �r�r�zNDFrame.filter.<locals>.f�s����~�~�j��m�4�D�@�@r�z,Must pass either `items`, `like`, or `regex`rt��return�bool_t)rsryr�r
r
rr~�intersectionr�r�r�r5r/r�re�compile)r�r�r��regexr��nkwrUr(r�r�r�s  `       @r��filterzNDFrame.filterNs'���L�#�#�E�4��7����7��)��
�
�<��'�'�D�����%�����&�&�t�,�D��%�L�-�-�f�5�E��5�z�Q�����V�\�\�2���4�<�<�0�4��-�0�0�
�
-��Z�Z��]�F��8�8��8�&�v�.�.�
�
A��j�j��'�G��Z�Z��]�F��8�8��8�&�v�.�.��J�K�Kr�c�n�t�r|jd|j�S|jd|S)a�
        Return the first `n` rows.

        This function returns the first `n` rows for the object based
        on position. It is useful for quickly testing if your object
        has the right type of data in it.

        For negative values of `n`, this function returns all rows except
        the last `|n|` rows, equivalent to ``df[:n]``.

        If n is larger than the number of rows, this function returns all rows.

        Parameters
        ----------
        n : int, default 5
            Number of rows to select.

        Returns
        -------
        same type as caller
            The first `n` rows of the caller object.

        See Also
        --------
        DataFrame.tail: Returns the last `n` rows.

        Examples
        --------
        >>> df = pd.DataFrame({'animal': ['alligator', 'bee', 'falcon', 'lion',
        ...                    'monkey', 'parrot', 'shark', 'whale', 'zebra']})
        >>> df
              animal
        0  alligator
        1        bee
        2     falcon
        3       lion
        4     monkey
        5     parrot
        6      shark
        7      whale
        8      zebra

        Viewing the first 5 lines

        >>> df.head()
              animal
        0  alligator
        1        bee
        2     falcon
        3       lion
        4     monkey

        Viewing the first `n` lines (three in this case)

        >>> df.head(3)
              animal
        0  alligator
        1        bee
        2     falcon

        For negative values of `n`

        >>> df.head(-3)
              animal
        0  alligator
        1        bee
        2     falcon
        3       lion
        4     monkey
        5     parrot
        N�rr|r��r��ns  r�r;zNDFrame.head�s4��R� ��9�9�R�a�=�%�%�'�'��y�y��!�}�r�c���t�r@|dk(r|jddj�S|j|dj�S|dk(r|jddS|j|dS)a�
        Return the last `n` rows.

        This function returns last `n` rows from the object based on
        position. It is useful for quickly verifying data, for example,
        after sorting or appending rows.

        For negative values of `n`, this function returns all rows except
        the first `|n|` rows, equivalent to ``df[|n|:]``.

        If n is larger than the number of rows, this function returns all rows.

        Parameters
        ----------
        n : int, default 5
            Number of rows to select.

        Returns
        -------
        type of caller
            The last `n` rows of the caller object.

        See Also
        --------
        DataFrame.head : The first `n` rows of the caller object.

        Examples
        --------
        >>> df = pd.DataFrame({'animal': ['alligator', 'bee', 'falcon', 'lion',
        ...                    'monkey', 'parrot', 'shark', 'whale', 'zebra']})
        >>> df
              animal
        0  alligator
        1        bee
        2     falcon
        3       lion
        4     monkey
        5     parrot
        6      shark
        7      whale
        8      zebra

        Viewing the last 5 lines

        >>> df.tail()
           animal
        4  monkey
        5  parrot
        6   shark
        7   whale
        8   zebra

        Viewing the last `n` lines (three in this case)

        >>> df.tail(3)
          animal
        6  shark
        7  whale
        8  zebra

        For negative values of `n`

        >>> df.tail(-3)
           animal
        3    lion
        4  monkey
        5  parrot
        6   shark
        7   whale
        8   zebra
        rNr�r�s  r��tailzNDFrame.tailso��R� ��A�v��y�y��1�~�*�*�,�,��9�9�a�R�S�>�&�&�(�(���6��9�9�Q�q�>�!��y�y�!���~�r��replacec��|�d}|j|�}|j|}tj|�}	t	j
|||�}
|
�|�J�t
||z�}
|�t	j|||�}t	j||
|||	�}|j||��}|rtt|��|_|S)uS
        Return a random sample of items from an axis of object.

        You can use `random_state` for reproducibility.

        Parameters
        ----------
        n : int, optional
            Number of items from axis to return. Cannot be used with `frac`.
            Default = 1 if `frac` = None.
        frac : float, optional
            Fraction of axis items to return. Cannot be used with `n`.
        replace : bool, default False
            Allow or disallow sampling of the same row more than once.
        weights : str or ndarray-like, optional
            Default 'None' results in equal probability weighting.
            If passed a Series, will align with target object on index. Index
            values in weights not found in sampled object will be ignored and
            index values in sampled object not in weights will be assigned
            weights of zero.
            If called on a DataFrame, will accept the name of a column
            when axis = 0.
            Unless weights are a Series, weights must be same length as axis
            being sampled.
            If weights do not sum to 1, they will be normalized to sum to 1.
            Missing values in the weights column will be treated as zero.
            Infinite values not allowed.
        random_state : int, array-like, BitGenerator, np.random.RandomState, np.random.Generator, optional
            If int, array-like, or BitGenerator, seed for random number generator.
            If np.random.RandomState or np.random.Generator, use as given.

            .. versionchanged:: 1.4.0

                np.random.Generator objects now accepted

        axis : {0 or 'index', 1 or 'columns', None}, default None
            Axis to sample. Accepts axis number or name. Default is stat axis
            for given data type. For `Series` this parameter is unused and defaults to `None`.
        ignore_index : bool, default False
            If True, the resulting index will be labeled 0, 1, …, n - 1.

            .. versionadded:: 1.3.0

        Returns
        -------
        Series or DataFrame
            A new object of same type as caller containing `n` items randomly
            sampled from the caller object.

        See Also
        --------
        DataFrameGroupBy.sample: Generates random samples from each group of a
            DataFrame object.
        SeriesGroupBy.sample: Generates random samples from each group of a
            Series object.
        numpy.random.choice: Generates a random sample from a given 1-D numpy
            array.

        Notes
        -----
        If `frac` > 1, `replacement` should be set to `True`.

        Examples
        --------
        >>> df = pd.DataFrame({'num_legs': [2, 4, 8, 0],
        ...                    'num_wings': [2, 0, 0, 0],
        ...                    'num_specimen_seen': [10, 2, 1, 8]},
        ...                   index=['falcon', 'dog', 'spider', 'fish'])
        >>> df
                num_legs  num_wings  num_specimen_seen
        falcon         2          2                 10
        dog            4          0                  2
        spider         8          0                  1
        fish           0          0                  8

        Extract 3 random elements from the ``Series`` ``df['num_legs']``:
        Note that we use `random_state` to ensure the reproducibility of
        the examples.

        >>> df['num_legs'].sample(n=3, random_state=1)
        fish      0
        spider    8
        falcon    2
        Name: num_legs, dtype: int64

        A random 50% sample of the ``DataFrame`` with replacement:

        >>> df.sample(frac=0.5, replace=True, random_state=1)
              num_legs  num_wings  num_specimen_seen
        dog          4          0                  2
        fish         0          0                  8

        An upsample sample of the ``DataFrame`` with replacement:
        Note that `replace` parameter has to be `True` for `frac` parameter > 1.

        >>> df.sample(frac=2, replace=True, random_state=1)
                num_legs  num_wings  num_specimen_seen
        dog            4          0                  2
        fish           0          0                  8
        falcon         2          2                 10
        falcon         2          2                 10
        fish           0          0                  8
        dog            4          0                  2
        fish           0          0                  8
        dog            4          0                  2

        Using a DataFrame column as weights. Rows with larger value in the
        `num_specimen_seen` column are more likely to be sampled.

        >>> df.sample(n=2, weights='num_specimen_seen', random_state=1)
                num_legs  num_wings  num_specimen_seen
        falcon         2          2                 10
        fish           0          0                  8
        rr�)rrKrs�random_staterw�process_sampling_sizer��preprocess_weightsr�r�r�r)
r�r��fracr��weightsr�r�rZ�obj_len�rsrQ�sampled_indicesrvs
             r�rwzNDFrame.sampleXs���z�<��D��$�$�T�*���*�*�T�"���
 �
 ��
.���+�+�A�t�W�=���<��#�#�#�����(�D����/�/��g�t�D�G� �-�-���w���L�����?���6���(��V��5�F�L��
r�c��t�r*tj|jd��|g|��i|��Stj||g|��i|��S)a�
        Apply chainable functions that expect Series or DataFrames.

        Parameters
        ----------
        func : function
            Function to apply to the {klass}.
            ``args``, and ``kwargs`` are passed into ``func``.
            Alternatively a ``(callable, data_keyword)`` tuple where
            ``data_keyword`` is a string indicating the keyword of
            ``callable`` that expects the {klass}.
        *args : iterable, optional
            Positional arguments passed into ``func``.
        **kwargs : mapping, optional
            A dictionary of keyword arguments passed into ``func``.

        Returns
        -------
        the return type of ``func``.

        See Also
        --------
        DataFrame.apply : Apply a function along input axis of DataFrame.
        DataFrame.map : Apply a function elementwise on a whole DataFrame.
        Series.map : Apply a mapping correspondence on a
            :class:`~pandas.Series`.

        Notes
        -----
        Use ``.pipe`` when chaining together functions that expect
        Series, DataFrames or GroupBy objects.

        Examples
        --------
        Constructing a income DataFrame from a dictionary.

        >>> data = [[8000, 1000], [9500, np.nan], [5000, 2000]]
        >>> df = pd.DataFrame(data, columns=['Salary', 'Others'])
        >>> df
           Salary  Others
        0    8000  1000.0
        1    9500     NaN
        2    5000  2000.0

        Functions that perform tax reductions on an income DataFrame.

        >>> def subtract_federal_tax(df):
        ...     return df * 0.9
        >>> def subtract_state_tax(df, rate):
        ...     return df * (1 - rate)
        >>> def subtract_national_insurance(df, rate, rate_increase):
        ...     new_rate = rate + rate_increase
        ...     return df * (1 - new_rate)

        Instead of writing

        >>> subtract_national_insurance(
        ...     subtract_state_tax(subtract_federal_tax(df), rate=0.12),
        ...     rate=0.05,
        ...     rate_increase=0.02)  # doctest: +SKIP

        You can write

        >>> (
        ...     df.pipe(subtract_federal_tax)
        ...     .pipe(subtract_state_tax, rate=0.12)
        ...     .pipe(subtract_national_insurance, rate=0.05, rate_increase=0.02)
        ... )
            Salary   Others
        0  5892.48   736.56
        1  6997.32      NaN
        2  3682.80  1473.12

        If you have a function that takes the data as (say) the second
        argument, pass a tuple indicating which keyword expects the
        data. For example, suppose ``national_insurance`` takes its data as ``df``
        in the second argument:

        >>> def subtract_national_insurance(rate, df, rate_increase):
        ...     new_rate = rate + rate_increase
        ...     return df * (1 - new_rate)
        >>> (
        ...     df.pipe(subtract_federal_tax)
        ...     .pipe(subtract_state_tax, rate=0.12)
        ...     .pipe(
        ...         (subtract_national_insurance, 'df'),
        ...         rate=0.05,
        ...         rate_increase=0.02
        ...     )
        ... )
            Salary   Others
        0  5892.48   736.56
        1  6997.32      NaN
        2  3682.80  1473.12
        Nr�)rrs�piper�)r��func�argsrs    r�r�zNDFrame.pipe�sL��N� ��;�;�t�y�y�d�y�3�T�K�D�K�F�K�K��{�{�4��7��7��7�7r�c
���t|t�r�|jrt|j�|_|jj
|j_t
|j�t
|j�zD]6}t|t�sJ�tj||t||d���8|dk(r�td�|jD��rL|jdj�t�fd�|jddD��}|rt��|_td�|jD��}||j_|S)a�
        Propagate metadata from other to self.

        Parameters
        ----------
        other : the object from which to get the attributes that we are going
            to propagate
        method : str, optional
            A passed method name providing context on where ``__finalize__``
            was called.

            .. warning::

               The value passed as `method` are not currently considered
               stable across pandas releases.
        Nr�c3�FK�|]}t|j����y�wr�)r�r�)rHr�s  r�rIz'NDFrame.__finalize__.<locals>.<genexpr>~s����9�j�s�4��	�	�?�j�s�!rc3�<�K�|]}|j�k(���y�wr�)r�)rHr�r�s  �r�rIz'NDFrame.__finalize__.<locals>.<genexpr>�s�����%S�N�S�c�i�i�5�&8�N���r�c3�HK�|]}|jj���y�wr�)r�r��rHr�s  r�rIz'NDFrame.__finalize__.<locals>.<genexpr>�s����*�9C�A����/�/��s� ")r�r�r�rr�r�r$r�r�r�r�r r��objs)r�r�rbrr(�have_same_attrsr�r�s       @r�r�zNDFrame.__finalize__\s���$�e�W�%��{�{�
&�e�k�k�2��
�16���1T�1T�D�J�J�.��D�N�N�+�c�%�/�/�.B�B��!�$��,�,�,��"�"�4��w�u�d�D�/I�J�C��X���9�e�j�j�9�9��
�
�1�
�+�+��"%�%S�E�J�J�q�r�N�%S�"S��"�!)�%��D�J�&)�*�9>���*�'�#�2I�D�J�J�.��r�c���||jvr<||jvr.||jvr |jj	|�r||St
j
||�S)z�
        After regular attribute access, try looking up the name
        This allows simpler access to columns for interactive use.
        )r�r�r�r?�$_can_hold_identifiers_and_holds_namer��__getattribute__)r�r(s  r��__getattr__zNDFrame.__getattr__�sY��
��0�0�0��D�N�N�*��D�O�O�+����D�D�T�J���:���&�&�t�T�2�2r�c��	tj||�tj|||�S#t$rYnwxYw||jvrtj|||�y||j
vrtj|||�y	t
||�}t|t�rtj|||�y||jvr|||<ytj|||�y#ttf$rTt|t�r*t|�rtjdt���tj|||�YywxYw)z�
        After regular attribute access, try setting the name
        This allows simpler access to columns for interactive use.
        z�Pandas doesn't allow columns to be created via a new attribute name - see https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-accessr�N)r�r�r��AttributeErrorr�r�r r�r~r?r�rkrcr�r�rU)r�r(r��existings    r�r�zNDFrame.__setattr__�s%��	��#�#�D�$�/��%�%�d�D�%�8�8���	��	��
�4�+�+�+����t�T�5�1�
�T�^�^�
#����t�T�5�1�
6�"�4��.���h��.��&�&�t�T�5�9��T�_�_�,�!&�D��J��&�&�t�T�5�9��"�I�.�	
6��d�L�1�|�E�7J��M�M�@�$4�#5���"�"�4��u�5�	
6�s+�,/�	;�;�3C+�?C+�C+�+A E�
Ec���t�|��}|jjr%|j	|jj
�|S)z�
        add the string-like attributes from the info_axis.
        If info_axis is a MultiIndex, its first level values are used.
        )�super�_dir_additionsr?�_can_hold_stringsr�_dir_additions_for_owner)r��	additions�	__class__s  �r�r�zNDFrame._dir_additions�s=����G�*�,�	��?�?�,�,����T�_�_�E�E�F��r�c��t|jttf�r|�St	|jj
�}|�}t	|jj
�|k7r|j
�|S)z^
        Consolidate _mgr -- if the blocks have changed, then clear the
        cache
        )r�r�r�r�r�r�r[)r�r��
blocks_beforervs    r��_protect_consolidatezNDFrame._protect_consolidate�sb���d�i�i�,�0B�!C�D��3�J��D�I�I�,�,�-�
�����t�y�y��� �M�1��"�"�$��
r�c�4��d�fd�}�j|�y)z)Consolidate data in place and return Nonec�D���jj��_yr��r��consolidater�s�r�r�z'NDFrame._consolidate_inplace.<locals>.f�s����	�	�-�-�/�D�Ir�N�r��None)r�)r�r�s` r��_consolidate_inplacezNDFrame._consolidate_inplace�s���	0�	
�!�!�!�$r�c����fd�}�j|�}�j||j��j��S)z�
        Compute NDFrame with "consolidated" internals (data of each dtype
        grouped together in a single ndarray).

        Returns
        -------
        consolidated : same type as caller
        c�8���jj�Sr�r�r�s�r�r�z&NDFrame._consolidate.<locals>.<lambda>�s���D�I�I�)�)�+r�r�)r�r�r�r�)r�r��	cons_datas`  r��_consolidatezNDFrame._consolidate�sD���
,���-�-�a�0�	��)�)�)�)�.�.�)�I�V�V��
�	
r�c��|jjry|jjry|jj	�dkDS)NFTr�)r�rg�any_extension_typesr<�nuniquer�s r��_is_mixed_typezNDFrame._is_mixed_type�s>���9�9�$�$���9�9�(�(���{�{�"�"�$�q�(�(r�c��|jj�}|j||j��j	|�S�Nr�)r��get_numeric_datar�r�r��r�r�s  r��_get_numeric_datazNDFrame._get_numeric_data
s:���)�)�,�,�.���)�)�'����)�E�R�R�SW�X�Xr�c��|jj�}|j||j��j	|�Sr�)r��
get_bool_datar�r�r�r�s  r��_get_bool_datazNDFrame._get_bool_datas:���)�)�)�)�+���)�)�'����)�E�R�R�SW�X�Xr�c��t|��r�r�r�s r�r�zNDFrame.valuess
��!�$�'�'r�c��t|��)zinternal implementationr�r�s r�rfzNDFrame._valuess��"�$�'�'r�c��|jj�}|j||jtj
��S)aJ
        Return the dtypes in the DataFrame.

        This returns a Series with the data type of each column.
        The result's index is the original DataFrame's columns. Columns
        with mixed types are stored with the ``object`` dtype. See
        :ref:`the User Guide <basics.dtypes>` for more.

        Returns
        -------
        pandas.Series
            The data type of each column.

        Examples
        --------
        >>> df = pd.DataFrame({'float': [1.0],
        ...                    'int': [1],
        ...                    'datetime': [pd.Timestamp('20180310')],
        ...                    'string': ['foo']})
        >>> df.dtypes
        float              float64
        int                  int64
        datetime    datetime64[ns]
        string              object
        dtype: object
        )rr�)r��
get_dtypes�_constructor_slicedr?rO�object_r�s  r�r<zNDFrame.dtypes s6��8�y�y�#�#�%���'�'��D�O�O�2�:�:�'�V�Vr�c	���|rt�rd}t���r(|jdk(rIt��dkDs|j�vrtd���|j}|j
|||�Sddlm}|�t��}|jD]}||vs�td|�d���|j|jd	d�
�}g}t|j��D][\}	\}}
|j|	}t!|�r|
j#|��}n	|
j
|||��}|j)|��]n�t+��r�|jdkDr�t-���t/�t0�r:t3�fd�|j4j6D��r|j#|��S|j�D��cgc]\}}|j
�||����}}}nN|j4j
�||��}|j9||j:��}|j=|d��S|s|j#d	��St?|dd��}|jA|�}|j|_|j=|d��}tCtD|�S#t$$r}
|
�d
|�d�f|
_�d	}
~
wwxYwcc}}w)a�
        Cast a pandas object to a specified dtype ``dtype``.

        Parameters
        ----------
        dtype : str, data type, Series or Mapping of column name -> data type
            Use a str, numpy.dtype, pandas.ExtensionDtype or Python type to
            cast entire pandas object to the same type. Alternatively, use a
            mapping, e.g. {col: dtype, ...}, where col is a column label and dtype is
            a numpy.dtype or Python type to cast one or more of the DataFrame's
            columns to column-specific types.
        copy : bool, default True
            Return a copy when ``copy=True`` (be very careful setting
            ``copy=False`` as changes to values then may propagate to other
            pandas objects).

            .. note::
                The `copy` keyword will change behavior in pandas 3.0.
                `Copy-on-Write
                <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
                will be enabled by default, which means that all methods with a
                `copy` keyword will use a lazy copy mechanism to defer the copy and
                ignore the `copy` keyword. The `copy` keyword will be removed in a
                future version of pandas.

                You can already get the future behavior and improvements through
                enabling copy on write ``pd.options.mode.copy_on_write = True``
        errors : {'raise', 'ignore'}, default 'raise'
            Control raising of exceptions on invalid data for provided dtype.

            - ``raise`` : allow exceptions to be raised
            - ``ignore`` : suppress exceptions. On error return original object.

        Returns
        -------
        same type as caller

        See Also
        --------
        to_datetime : Convert argument to datetime.
        to_timedelta : Convert argument to timedelta.
        to_numeric : Convert argument to a numeric type.
        numpy.ndarray.astype : Cast a numpy array to a specified type.

        Notes
        -----
        .. versionchanged:: 2.0.0

            Using ``astype`` to convert from timezone-naive dtype to
            timezone-aware dtype will raise an exception.
            Use :meth:`Series.dt.tz_localize` instead.

        Examples
        --------
        Create a DataFrame:

        >>> d = {'col1': [1, 2], 'col2': [3, 4]}
        >>> df = pd.DataFrame(data=d)
        >>> df.dtypes
        col1    int64
        col2    int64
        dtype: object

        Cast all columns to int32:

        >>> df.astype('int32').dtypes
        col1    int32
        col2    int32
        dtype: object

        Cast col1 to int32 using a dictionary:

        >>> df.astype({'col1': 'int32'}).dtypes
        col1    int32
        col2    int64
        dtype: object

        Create a series:

        >>> ser = pd.Series([1, 2], dtype='int32')
        >>> ser
        0    1
        1    2
        dtype: int32
        >>> ser.astype('int64')
        0    1
        1    2
        dtype: int64

        Convert to categorical type:

        >>> ser.astype('category')
        0    1
        1    2
        dtype: category
        Categories (2, int32): [1, 2]

        Convert to ordered categorical type with custom ordering:

        >>> from pandas.api.types import CategoricalDtype
        >>> cat_dtype = CategoricalDtype(
        ...     categories=[2, 1], ordered=True)
        >>> ser.astype(cat_dtype)
        0    1
        1    2
        dtype: category
        Categories (2, int64): [2 < 1]

        Create a series of dates:

        >>> ser_date = pd.Series(pd.date_range('20200101', periods=3))
        >>> ser_date
        0   2020-01-01
        1   2020-01-02
        2   2020-01-03
        dtype: datetime64[ns]
        Fr�zFOnly the Series name can be used for the key in Series dtype mappings.rr8r�zJOnly a column name can be used for the key in a dtype mappings argument. 'z' not found in columns.N)ror�r�)r�r�r~z': Error while type casting for column 'r^c3�<�K�|]}|j�k(���y�wr�r�)rHrr�s  �r�rIz!NDFrame.astype.<locals>.<genexpr>�s�����9�.>�s��	�	�U�"�.>�r�)r�r~r�r�rarR)#rrarr�r(rr��pandasr�r�rr5rr!r��iatror�rr�rqrbrhr�rjr�r��arraysr�r�r�r�r�r
r8)r�r�r�r~�new_typer��	dtype_ser�col_name�resultsr'r��cdt�res_col�ex�_�serr�r�rvs `                 r�r�zNDFrame.astype?s����r�'�)��D�����y�y�A�~��u�:��>�T�Y�Y�e�%;�"�<���!����+���{�{�8�T�6�:�:�
&��u�F�3�I�%�O�O���4�'�"��$�:�%<�>���,�"�)�)�$�,�,�4�e�)�T�I��G�&/��
�
��&=�"��?�H�c��m�m�A�&����9�!�h�h�D�h�1�G��"%�*�*�3�T�&�*�"Q�����w�'�'>�&�e�
,����Q�� ��'�E��%��0�S�9�.2�i�i�.>�.>�9�6��y�y�d�y�+�+�KO�*�*�,��JV���3��
�
�5�t�F�
�;�,�
���y�y�'�'�e�$�v�'�N�H��,�,�X�H�M�M�,�J�C��#�#�D��#�:�:���9�9�$�9�'�'���a�e�4���"�"�6�*��������$�$�T�(�$�;���D�&�!�!��O&��!�d�"I�(��ST�U�#�����	�� s�J�J=�	J:�&J5�5J:c��|jj|��}|j�|j||j��j|d��S)a�
        Make a copy of this object's indices and data.

        When ``deep=True`` (default), a new object will be created with a
        copy of the calling object's data and indices. Modifications to
        the data or indices of the copy will not be reflected in the
        original object (see notes below).

        When ``deep=False``, a new object will be created without copying
        the calling object's data or index (only references to the data
        and index are copied). Any changes to the data of the original
        will be reflected in the shallow copy (and vice versa).

        .. note::
            The ``deep=False`` behaviour as described above will change
            in pandas 3.0. `Copy-on-Write
            <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
            will be enabled by default, which means that the "shallow" copy
            is that is returned with ``deep=False`` will still avoid making
            an eager copy, but changes to the data of the original will *no*
            longer be reflected in the shallow copy (or vice versa). Instead,
            it makes use of a lazy (deferred) copy mechanism that will copy
            the data only when any changes to the original or shallow copy is
            made.

            You can already get the future behavior and improvements through
            enabling copy on write ``pd.options.mode.copy_on_write = True``

        Parameters
        ----------
        deep : bool, default True
            Make a deep copy, including a copy of the data and the indices.
            With ``deep=False`` neither the indices nor the data are copied.

        Returns
        -------
        Series or DataFrame
            Object type matches caller.

        Notes
        -----
        When ``deep=True``, data is copied but actual Python objects
        will not be copied recursively, only the reference to the object.
        This is in contrast to `copy.deepcopy` in the Standard Library,
        which recursively copies object data (see examples below).

        While ``Index`` objects are copied when ``deep=True``, the underlying
        numpy array is not copied for performance reasons. Since ``Index`` is
        immutable, the underlying data can be safely shared and a copy
        is not needed.

        Since pandas is not thread safe, see the
        :ref:`gotchas <gotchas.thread-safety>` when copying in a threading
        environment.

        When ``copy_on_write`` in pandas config is set to ``True``, the
        ``copy_on_write`` config takes effect even when ``deep=False``.
        This means that any changes to the copied data would make a new copy
        of the data upon write (and vice versa). Changes made to either the
        original or copied variable would not be reflected in the counterpart.
        See :ref:`Copy_on_Write <copy_on_write>` for more information.

        Examples
        --------
        >>> s = pd.Series([1, 2], index=["a", "b"])
        >>> s
        a    1
        b    2
        dtype: int64

        >>> s_copy = s.copy()
        >>> s_copy
        a    1
        b    2
        dtype: int64

        **Shallow copy versus default (deep) copy:**

        >>> s = pd.Series([1, 2], index=["a", "b"])
        >>> deep = s.copy()
        >>> shallow = s.copy(deep=False)

        Shallow copy shares data and index with original.

        >>> s is shallow
        False
        >>> s.values is shallow.values and s.index is shallow.index
        True

        Deep copy has own copy of data and index.

        >>> s is deep
        False
        >>> s.values is deep.values or s.index is deep.index
        False

        Updates to the data shared by shallow copy and original is reflected
        in both (NOTE: this will no longer be true for pandas >= 3.0);
        deep copy remains unchanged.

        >>> s.iloc[0] = 3
        >>> shallow.iloc[1] = 4
        >>> s
        a    3
        b    4
        dtype: int64
        >>> shallow
        a    3
        b    4
        dtype: int64
        >>> deep
        a    1
        b    2
        dtype: int64

        Note that when copying an object containing Python objects, a deep copy
        will copy the data, but will not do so recursively. Updating a nested
        data object will be reflected in the deep copy.

        >>> s = pd.Series([[1, 2], [3, 4]])
        >>> deep = s.copy()
        >>> s[0][0] = 10
        >>> s
        0    [10, 2]
        1     [3, 4]
        dtype: object
        >>> deep
        0    [10, 2]
        1     [3, 4]
        dtype: object

        **Copy-on-Write is set to true**, the shallow copy is not modified
        when the original data is changed:

        >>> with pd.option_context("mode.copy_on_write", True):
        ...     s = pd.Series([1, 2], index=["a", "b"])
        ...     copy = s.copy(deep=False)
        ...     s.iloc[0] = 100
        ...     s
        a    100
        b      2
        dtype: int64
        >>> copy
        a    1
        b    2
        dtype: int64
        r�r�r�ra)r�r�r[r�r�r�)r�r�r�s   r�r�zNDFrame.copysW��j�y�y�~�~�4�~�(����� ��)�)�$�T�Y�Y�)�?�L�L���M�
�	
r�c�&�|j|��SrXr)r�r�s  r��__copy__zNDFrame.__copy__�s���y�y�d�y�#�#r�c�&�|jd��S)zq
        Parameters
        ----------
        memo, default None
            Standard signature. Unused
        Tr�r)r��memos  r��__deepcopy__zNDFrame.__deepcopy__�s���y�y�d�y�#�#r�c��|jj|��}|j||j��}|j	|d��S)a�
        Attempt to infer better dtypes for object columns.

        Attempts soft conversion of object-dtyped
        columns, leaving non-object and unconvertible
        columns unchanged. The inference rules are the
        same as during normal Series/DataFrame construction.

        Parameters
        ----------
        copy : bool, default True
            Whether to make a copy for non-object or non-inferable columns
            or Series.

            .. note::
                The `copy` keyword will change behavior in pandas 3.0.
                `Copy-on-Write
                <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
                will be enabled by default, which means that all methods with a
                `copy` keyword will use a lazy copy mechanism to defer the copy and
                ignore the `copy` keyword. The `copy` keyword will be removed in a
                future version of pandas.

                You can already get the future behavior and improvements through
                enabling copy on write ``pd.options.mode.copy_on_write = True``

        Returns
        -------
        same type as input object

        See Also
        --------
        to_datetime : Convert argument to datetime.
        to_timedelta : Convert argument to timedelta.
        to_numeric : Convert argument to numeric type.
        convert_dtypes : Convert argument to best possible dtype.

        Examples
        --------
        >>> df = pd.DataFrame({"A": ["a", 1, 2, 3]})
        >>> df = df.iloc[1:]
        >>> df
           A
        1  1
        2  2
        3  3

        >>> df.dtypes
        A    object
        dtype: object

        >>> df.infer_objects().dtypes
        A    int64
        dtype: object
        rr��
infer_objectsra)r��convertr�r�r�)r�r�r�r�s    r�r�zNDFrame.infer_objects�sK��r�)�)�#�#��#�.���(�(��w�|�|�(�D������_��=�=r�c��t|�|jj||||||��}|j||j��}|j|d��S)a�
        Convert columns to the best possible dtypes using dtypes supporting ``pd.NA``.

        Parameters
        ----------
        infer_objects : bool, default True
            Whether object dtypes should be converted to the best possible types.
        convert_string : bool, default True
            Whether object dtypes should be converted to ``StringDtype()``.
        convert_integer : bool, default True
            Whether, if possible, conversion can be done to integer extension types.
        convert_boolean : bool, defaults True
            Whether object dtypes should be converted to ``BooleanDtypes()``.
        convert_floating : bool, defaults True
            Whether, if possible, conversion can be done to floating extension types.
            If `convert_integer` is also True, preference will be give to integer
            dtypes if the floats can be faithfully casted to integers.
        dtype_backend : {'numpy_nullable', 'pyarrow'}, default 'numpy_nullable'
            Back-end data type applied to the resultant :class:`DataFrame`
            (still experimental). Behaviour is as follows:

            * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame`
              (default).
            * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype`
              DataFrame.

            .. versionadded:: 2.0

        Returns
        -------
        Series or DataFrame
            Copy of input object with new dtype.

        See Also
        --------
        infer_objects : Infer dtypes of objects.
        to_datetime : Convert argument to datetime.
        to_timedelta : Convert argument to timedelta.
        to_numeric : Convert argument to a numeric type.

        Notes
        -----
        By default, ``convert_dtypes`` will attempt to convert a Series (or each
        Series in a DataFrame) to dtypes that support ``pd.NA``. By using the options
        ``convert_string``, ``convert_integer``, ``convert_boolean`` and
        ``convert_floating``, it is possible to turn off individual conversions
        to ``StringDtype``, the integer extension types, ``BooleanDtype``
        or floating extension types, respectively.

        For object-dtyped columns, if ``infer_objects`` is ``True``, use the inference
        rules as during normal Series/DataFrame construction.  Then, if possible,
        convert to ``StringDtype``, ``BooleanDtype`` or an appropriate integer
        or floating extension type, otherwise leave as ``object``.

        If the dtype is integer, convert to an appropriate integer extension type.

        If the dtype is numeric, and consists of all integers, convert to an
        appropriate integer extension type. Otherwise, convert to an
        appropriate floating extension type.

        In the future, as new dtypes are added that support ``pd.NA``, the results
        of this method will change to support those new dtypes.

        Examples
        --------
        >>> df = pd.DataFrame(
        ...     {
        ...         "a": pd.Series([1, 2, 3], dtype=np.dtype("int32")),
        ...         "b": pd.Series(["x", "y", "z"], dtype=np.dtype("O")),
        ...         "c": pd.Series([True, False, np.nan], dtype=np.dtype("O")),
        ...         "d": pd.Series(["h", "i", np.nan], dtype=np.dtype("O")),
        ...         "e": pd.Series([10, np.nan, 20], dtype=np.dtype("float")),
        ...         "f": pd.Series([np.nan, 100.5, 200], dtype=np.dtype("float")),
        ...     }
        ... )

        Start with a DataFrame with default dtypes.

        >>> df
           a  b      c    d     e      f
        0  1  x   True    h  10.0    NaN
        1  2  y  False    i   NaN  100.5
        2  3  z    NaN  NaN  20.0  200.0

        >>> df.dtypes
        a      int32
        b     object
        c     object
        d     object
        e    float64
        f    float64
        dtype: object

        Convert the DataFrame to use best possible dtypes.

        >>> dfn = df.convert_dtypes()
        >>> dfn
           a  b      c     d     e      f
        0  1  x   True     h    10   <NA>
        1  2  y  False     i  <NA>  100.5
        2  3  z   <NA>  <NA>    20  200.0

        >>> dfn.dtypes
        a             Int32
        b    string[python]
        c           boolean
        d    string[python]
        e             Int64
        f           Float64
        dtype: object

        Start with a Series of strings and missing data represented by ``np.nan``.

        >>> s = pd.Series(["a", "b", np.nan])
        >>> s
        0      a
        1      b
        2    NaN
        dtype: object

        Obtain a Series with dtype ``StringDtype``.

        >>> s.convert_dtypes()
        0       a
        1       b
        2    <NA>
        dtype: string
        )r��convert_string�convert_integer�convert_boolean�convert_floating�
dtype_backendr��convert_dtypesra)rVr�r�r�r�r�)	r�r�r�r�r�r�r�r�r�s	         r�r�zNDFrame.convert_dtypes�sj��T	�M�*��)�)�*�*�'�)�+�+�-�'�
+�
���(�(��w�|�|�(�D������-=��>�>r�c��|tjur*tjd|�d�tt���|Sd}|S)N�The 'downcast' keyword in z� is deprecated and will be removed in a future version. Use res.infer_objects(copy=False) to infer non-object dtype, or pd.to_numeric with the 'downcast' keyword to downcast numeric results.r�)rr�r�r�rcrU)r��downcast�method_names   r��_deprecate_downcastzNDFrame._deprecate_downcast�sI���3�>�>�)��M�M�,�[�M�:��
�+�-�
����H��r��r�r�r3�
limit_arear�c���|�d}|j|�}t|�}|jjs;|dk(r6|r
t	��|j
j
|||��j
}|S|jj||j|�||||��}|j||j��}|r|j|�S|j|d��S)Nrr�)rbr3r��rbr�r3r�r�r�r��fillnara)
rr�r�rgr�r=�_pad_or_backfill�pad_or_backfillr�r�r�r�r�)	r�rbr�r�r3r�r�rvr�s	         r�rzNDFrame._pad_or_backfill�s����<��D��$�$�T�*��"�6�*���y�y�(�(�T�Q�Y��)�+�+��V�V�,�,��U�z�-���a�
��M��)�)�+�+���-�-�d�3��!���
,�
���+�+�G�'�,�,�+�G����'�'��/�/��&�&�t�H�&�=�=r�)rbr�r�r3r�c��yr�rt�r�r�rbr�r�r3r�s       r�r�zNDFrame.fillna�r�r�)rbr�r3r�c��yr�rtrs       r�r�zNDFrame.fillna�r�r�c��yr�rtrs       r�r�zNDFrame.fillna�r�r�r�)r�r�c��t|d�}|r�tsGt�r=tj|�t
kr�t
jttd��n�tszt�sp|j�r`tj|�}t
}t|t�rt|�r|dz
}||kr t
jttd��t!||�\}}|�:t
jt#|�j$�d�tt'���|t(j*u}	|j-|d�}|�d}|j/|�}|�|j1|||||�	�S|j2dk(r�t|t4tf�rXt7|�s|ry|j9d�
�Sddlm}
|
|�}|j?|j@d�
�}|jB}n.tE|�sn"tGdt#|�j$�d���|jHjK||||��}�n<t|t4tf��r`|dk(rtMd��t�r|j9d�
�}n|r|n|j9�}t|t4�}
|jO�D�]�\}}||vr�|	rt(j*}n|
s|n|jQ|�}||jK|||��}|s|||<�St|t�r6|jR||jRk(r||jTdd�|f<��|||<��|jVjY|�}t|tZ�r&t]j^|j`d�|}n�t|t\jb�r-|jRjddk(r|jg�d}n>t|t\jb�r|jRjddk(stMd��ti|�D]j\}}|jjdd�|f}|jjdd�|f}|jR|jRk(r||jjdd�|f<�Y|jm||��l���|r|jo|�S|StE|�sY|dk(r4|jpjK||��jp}|jH}n�|jHjK||||��}nat|tr�r:|j2dk(r+|ju|jw�|�jH}ntydt#|�����|j{||j|��}|r|jo|�S|j|d��S)aW
        Fill NA/NaN values using the specified method.

        Parameters
        ----------
        value : scalar, dict, Series, or DataFrame
            Value to use to fill holes (e.g. 0), alternately a
            dict/Series/DataFrame of values specifying which value to use for
            each index (for a Series) or column (for a DataFrame).  Values not
            in the dict/Series/DataFrame will not be filled. This value cannot
            be a list.
        method : {{'backfill', 'bfill', 'ffill', None}}, default None
            Method to use for filling holes in reindexed Series:

            * ffill: propagate last valid observation forward to next valid.
            * backfill / bfill: use next valid observation to fill gap.

            .. deprecated:: 2.1.0
                Use ffill or bfill instead.

        axis : {axes_single_arg}
            Axis along which to fill missing values. For `Series`
            this parameter is unused and defaults to 0.
        inplace : bool, default False
            If True, fill in-place. Note: this will modify any
            other views on this object (e.g., a no-copy slice for a column in a
            DataFrame).
        limit : int, default None
            If method is specified, this is the maximum number of consecutive
            NaN values to forward/backward fill. In other words, if there is
            a gap with more than this number of consecutive NaNs, it will only
            be partially filled. If method is not specified, this is the
            maximum number of entries along the entire axis where NaNs will be
            filled. Must be greater than 0 if not None.
        downcast : dict, default is None
            A dict of item->dtype of what to downcast if possible,
            or the string 'infer' which will try to downcast to an appropriate
            equal type (e.g. float64 to int64 if possible).

            .. deprecated:: 2.2.0

        Returns
        -------
        {klass} or None
            Object with missing values filled or None if ``inplace=True``.

        See Also
        --------
        ffill : Fill values by propagating the last valid observation to next valid.
        bfill : Fill values by using the next valid observation to fill the gap.
        interpolate : Fill NaN values using interpolation.
        reindex : Conform object to new index.
        asfreq : Convert TimeSeries to specified frequency.

        Examples
        --------
        >>> df = pd.DataFrame([[np.nan, 2, np.nan, 0],
        ...                    [3, 4, np.nan, 1],
        ...                    [np.nan, np.nan, np.nan, np.nan],
        ...                    [np.nan, 3, np.nan, 4]],
        ...                   columns=list("ABCD"))
        >>> df
             A    B   C    D
        0  NaN  2.0 NaN  0.0
        1  3.0  4.0 NaN  1.0
        2  NaN  NaN NaN  NaN
        3  NaN  3.0 NaN  4.0

        Replace all NaN elements with 0s.

        >>> df.fillna(0)
             A    B    C    D
        0  0.0  2.0  0.0  0.0
        1  3.0  4.0  0.0  1.0
        2  0.0  0.0  0.0  0.0
        3  0.0  3.0  0.0  4.0

        Replace all NaN elements in column 'A', 'B', 'C', and 'D', with 0, 1,
        2, and 3 respectively.

        >>> values = {{"A": 0, "B": 1, "C": 2, "D": 3}}
        >>> df.fillna(value=values)
             A    B    C    D
        0  0.0  2.0  2.0  0.0
        1  3.0  4.0  2.0  1.0
        2  0.0  1.0  2.0  3.0
        3  0.0  3.0  2.0  4.0

        Only replace the first NaN element.

        >>> df.fillna(value=values, limit=1)
             A    B    C    D
        0  0.0  2.0  2.0  0.0
        1  3.0  4.0  NaN  1.0
        2  NaN  1.0  NaN  3.0
        3  NaN  3.0  NaN  4.0

        When filling using a DataFrame, replacement happens along
        the same column names and same indices

        >>> df2 = pd.DataFrame(np.zeros((4, 4)), columns=list("ABCE"))
        >>> df.fillna(df2)
             A    B    C    D
        0  0.0  2.0  0.0  0.0
        1  3.0  4.0  0.0  1.0
        2  0.0  0.0  0.0  NaN
        3  0.0  3.0  0.0  4.0

        Note that column D is not affected since it is not present in df2.
        r�rr�r�Nzo.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead.r�r)r�r3r�r�r�r8FrzF"value" parameter must be a scalar, dict or Series, but you passed a "�")r�r3r�r�z9Currently only can fill with dict/Series column by column)r3r��br'zVUnexpected get_loc result, please report a bug at https://github.com/pandas-dev/pandas)r�r3zinvalid fill value with a r�ra)@rXrGr�sys�getrefcountrHr�r�rPrLrCr�rlrRrQrcrYrr�rUrr�r�rrrr�r�r�r�r�r5rrfrcr�r�r�r�r�rer�rrrrzrOr�rKrr�rr!r|�isetitemr�r=rk�whererprr�r�r�)r�r�rbr�r�r3r��ctr�	ref_count�was_no_defaultr�r�rv�is_dictr4r5�
downcast_k�res_k�locsr'r�res_locrls                       r�r�zNDFrame.fillna�s$��z&�g�y�9����/�1��?�?�4�(�I�5��M�M�6�.�#$���+�-��1�1�3��o�o�d�+��%�	��d�I�.�=��3F���N�I��)�#��M�M�>�%�#$��/�u�f�=�
��v����M�M���:�&�&�'�(���+�-�
�"�S�^�^�3���+�+�H�h�?���<��D��$�$�T�*���=��(�(�����
"�)�
�

��y�y�A�~��e�d�I�%6�7��u�:�"�#'�#�y�y�d�y�3�3�-�"�5�M�E�!�M�M�$�*�*�5�M�A�E�!�M�M�E�%�e�,��#�� ��K�0�0�1��4��� �9�9�+�+��u�g��,����E�D�)�#4�5��1�9�-�$���
'�(�!�Y�Y�D�Y�1�F�%,�T�$�)�)�+�F�$�X�t�4��!�K�K�M�D�A�q���� �%�%(�^�^�
�$+�%�"*���a��#�#�1�I�,�,�Q�e�j�,�Q�E�"�$)��q�	�&�e�Y�7�$�{�{�f�Q�i�o�o�=�38��
�
�1�a�4� 0�-2��q�	�$*�>�>�#9�#9�!�#<�D�)�$��6�')�y�y����A��'?��'E�� *�4���� <������TW�AW�'+�|�|�~�a�'8�� *�4���� <������TW�AW�':�%K�'"�!"�
+4�D�/���3�*/�*�*�Q��T�*:��)-���1�c�6�):��#*�=�=�F�L�L�#@�:A�F�K�K��3��$7�$*�O�O�C��$A�+:�g*�v��/�/��7�7�!�M�!�%�(��1�9�!�V�V�]�]��e�]�D�F�F�F�%�{�{�H�#�y�y�/�/�#�5�'�H� 0� �H��E�<�0�T�Y�Y�!�^��:�:�d�j�j�l�E�:�?�?�� �#=�d�5�k�]�!K�L�L��+�+�H�8�=�=�+�I����'�'��/�/��&�&�t�H�&�=�=r�c��yr�rt�r�r�r�r3r�r�s      r��ffillz
NDFrame.ffill���	r�)r�r3r�r�c��yr�rtrs      r�rz
NDFrame.ffill$rr�c��yr�rtrs      r�rz
NDFrame.ffill0rr�c�
�|j|d�}t|d�}|r�tsGt�r=t	j
|�tkr�tjttd��n�tszt�sp|j�r`t	j
|�}t}t|t�rt|�r|dz
}||kr tjtt d��|j#d|||||��S)a/

        Fill NA/NaN values by propagating the last valid observation to next valid.

        Parameters
        ----------
        axis : {axes_single_arg}
            Axis along which to fill missing values. For `Series`
            this parameter is unused and defaults to 0.
        inplace : bool, default False
            If True, fill in-place. Note: this will modify any
            other views on this object (e.g., a no-copy slice for a column in a
            DataFrame).
        limit : int, default None
            If method is specified, this is the maximum number of consecutive
            NaN values to forward/backward fill. In other words, if there is
            a gap with more than this number of consecutive NaNs, it will only
            be partially filled. If method is not specified, this is the
            maximum number of entries along the entire axis where NaNs will be
            filled. Must be greater than 0 if not None.
        limit_area : {{`None`, 'inside', 'outside'}}, default None
            If limit is specified, consecutive NaNs will be filled with this
            restriction.

            * ``None``: No fill restriction.
            * 'inside': Only fill NaNs surrounded by valid values
              (interpolate).
            * 'outside': Only fill NaNs outside valid values (extrapolate).

            .. versionadded:: 2.2.0

        downcast : dict, default is None
            A dict of item->dtype of what to downcast if possible,
            or the string 'infer' which will try to downcast to an appropriate
            equal type (e.g. float64 to int64 if possible).

            .. deprecated:: 2.2.0

        Returns
        -------
        {klass} or None
            Object with missing values filled or None if ``inplace=True``.

        Examples
        --------
        >>> df = pd.DataFrame([[np.nan, 2, np.nan, 0],
        ...                    [3, 4, np.nan, 1],
        ...                    [np.nan, np.nan, np.nan, np.nan],
        ...                    [np.nan, 3, np.nan, 4]],
        ...                   columns=list("ABCD"))
        >>> df
             A    B   C    D
        0  NaN  2.0 NaN  0.0
        1  3.0  4.0 NaN  1.0
        2  NaN  NaN NaN  NaN
        3  NaN  3.0 NaN  4.0

        >>> df.ffill()
             A    B   C    D
        0  NaN  2.0 NaN  0.0
        1  3.0  4.0 NaN  1.0
        2  3.0  4.0 NaN  1.0
        3  3.0  3.0 NaN  4.0

        >>> ser = pd.Series([1, np.nan, 2, 3])
        >>> ser.ffill()
        0   1.0
        1   1.0
        2   2.0
        3   3.0
        dtype: float64
        rr�rr�r�r��r�rXrGrr	r
rHr�r�rPrLrCr�rlrRrQrcr�r�r�r�r3r�r�r
rs        r�rz
NDFrame.ffill<s���j�+�+�H�g�>��%�g�y�9����/�1��?�?�4�(�I�5��M�M�6�.�#$���+�-��1�1�3��o�o�d�+��%�	��d�I�.�=��3F���N�I��)�#��M�M�>�%�#$���$�$�����!��%�

�
	
r��r�r�r3r�c�t�tjdtt���|j	||||��S)a�
        Fill NA/NaN values by propagating the last valid observation to next valid.

        .. deprecated:: 2.0

            {klass}.pad is deprecated. Use {klass}.ffill instead.

        Returns
        -------
        {klass} or None
            Object with missing values filled or None if ``inplace=True``.

        Examples
        --------
        Please see examples for :meth:`DataFrame.ffill` or :meth:`Series.ffill`.
        zPDataFrame.pad/Series.pad is deprecated. Use DataFrame.ffill/Series.ffill insteadr�r)r�r�rcrUr�r�r�r�r3r�s     r��padzNDFrame.pad��7��4	�
�
�
3��'�)�		
��z�z�t�W�E�H�z�U�Ur�c��yr�rtrs      r��bfillz
NDFrame.bfill�rr�)r�r3r�c��yr�rtr s     r�r$z
NDFrame.bfill�s��	r�c��yr�rtrs      r�r$z
NDFrame.bfill�rr�c�
�|j|d�}t|d�}|r�tsGt�r=t	j
|�tkr�tjttd��n�tszt�sp|j�r`t	j
|�}t}t|t�rt|�r|dz
}||kr tjtt d��|j#d|||||��S)aU

        Fill NA/NaN values by using the next valid observation to fill the gap.

        Parameters
        ----------
        axis : {axes_single_arg}
            Axis along which to fill missing values. For `Series`
            this parameter is unused and defaults to 0.
        inplace : bool, default False
            If True, fill in-place. Note: this will modify any
            other views on this object (e.g., a no-copy slice for a column in a
            DataFrame).
        limit : int, default None
            If method is specified, this is the maximum number of consecutive
            NaN values to forward/backward fill. In other words, if there is
            a gap with more than this number of consecutive NaNs, it will only
            be partially filled. If method is not specified, this is the
            maximum number of entries along the entire axis where NaNs will be
            filled. Must be greater than 0 if not None.
        limit_area : {{`None`, 'inside', 'outside'}}, default None
            If limit is specified, consecutive NaNs will be filled with this
            restriction.

            * ``None``: No fill restriction.
            * 'inside': Only fill NaNs surrounded by valid values
              (interpolate).
            * 'outside': Only fill NaNs outside valid values (extrapolate).

            .. versionadded:: 2.2.0

        downcast : dict, default is None
            A dict of item->dtype of what to downcast if possible,
            or the string 'infer' which will try to downcast to an appropriate
            equal type (e.g. float64 to int64 if possible).

            .. deprecated:: 2.2.0

        Returns
        -------
        {klass} or None
            Object with missing values filled or None if ``inplace=True``.

        Examples
        --------
        For Series:

        >>> s = pd.Series([1, None, None, 2])
        >>> s.bfill()
        0    1.0
        1    2.0
        2    2.0
        3    2.0
        dtype: float64
        >>> s.bfill(limit=1)
        0    1.0
        1    NaN
        2    2.0
        3    2.0
        dtype: float64

        With DataFrame:

        >>> df = pd.DataFrame({{'A': [1, None, None, 4], 'B': [None, 5, None, 7]}})
        >>> df
              A     B
        0   1.0	  NaN
        1   NaN	  5.0
        2   NaN   NaN
        3   4.0   7.0
        >>> df.bfill()
              A     B
        0   1.0   5.0
        1   4.0   5.0
        2   4.0   7.0
        3   4.0   7.0
        >>> df.bfill(limit=1)
              A     B
        0   1.0   5.0
        1   NaN   5.0
        2   4.0   7.0
        3   4.0   7.0
        r$r�rr�r�r�rrs        r�r$z
NDFrame.bfill�s���@�+�+�H�g�>��%�g�y�9����/�1��?�?�4�(�I�5��M�M�6�.�#$���+�-��1�1�3��o�o�d�+��%�	��d�I�.�=��3F���N�I��)�#��M�M�>�%�#$���$�$�����!��%�

�
	
r�c�t�tjdtt���|j	||||��S)a�
        Fill NA/NaN values by using the next valid observation to fill the gap.

        .. deprecated:: 2.0

            {klass}.backfill is deprecated. Use {klass}.bfill instead.

        Returns
        -------
        {klass} or None
            Object with missing values filled or None if ``inplace=True``.

        Examples
        --------
        Please see examples for :meth:`DataFrame.bfill` or :meth:`Series.bfill`.
        zZDataFrame.backfill/Series.backfill is deprecated. Use DataFrame.bfill/Series.bfill insteadr�r)r�r�rcrUr$r s     r��backfillzNDFrame.backfill�r"r�)r�r3r�rbc��yr�rt�r��
to_replacer�r�r3r�rbs       r�r�zNDFrame.replace�r�r�)r3r�rbc��yr�rtr+s       r�r�zNDFrame.replace�r�r�c��yr�rtr+s       r�r�zNDFrame.replace�r�r�)r�r�c��
�|tjur<tjdt	|�j
�d�tt���n=|�;tjdt	|�j
�d�tt���|tjur[|tjurIt|�s>|dur:tjt	|�j
�d�tt���t|�s@t|�s5t|�s*tdtt	|�j
�����t|d�}|r�tsGt!�r=t#j$|�t&kr�tjt(t*d	��n�tszt!�sp|j-�r`t#j$|�}t&}t/|t0�rt3|�r|d
z
}||kr tjt4td	��t7|�s
|�t9d��|tjus|tju�r�|tjurd}t|�st|�s|g}t/|t:t<f�rPt/|t>�r,d
dl m!}	|jE|	jF||||f��}
|ry|
S|jG||||�St|�st|�std��|}d}t=|jI��}|rtK|�\}}
ngg}
}|
D�cgc]
}t|���}}tM|�rmtO|�std��i}i}|D]I\}}t=tK|jI���xsggf\}}
t=|�||<t=|
�||<�K||}}n||
}}|jQ|||||��S|jRs|ry|jUd��St|�r�t|�rO|jW�D�cic]#}||jW�vr||vr|||||f��%}}|jY|||�St|�sR|jZd
k(rt9d��|jI�D��cic]
\}}|||f��}}}|jY|||�Std��t|�rvt|�s|gt]|�z}t]|�t]|�k7r$t9dt]|��dt]|��d���|j^ja||||��}�nA|�at|�s@t|�s5t|�s*tdtt	|�j
�����|jQ||||d��St|�rR|jZd
k(rt9d��|jI�D��cic]
\}}|||f��}}}|jY|||�St|�sLtc||�}|r|j^je|||��}nI|j^jQ|||��}n*tdtt	|�j
�����|jg||jh��}
|r|jk|
�S|
jm|d �!�Scc}wcc}wcc}}wcc}}w)"NzThe 'method' keyword in z?.replace is deprecated and will be removed in a future version.r�zThe 'limit' keyword in Fz�.replace without 'value' and with non-dict-like 'to_replace' is deprecated and will raise in a future version. Explicitly specify the new values instead.zYExpecting 'to_replace' to be either a scalar, array-like, dict or None, got invalid type r�rr�z4'to_replace' must be 'None' if 'regex' is not a boolr!rr8)r�zfIf "to_replace" and "value" are both None and "to_replace" is not a list, then regex must be a mappingTzSIf a nested mapping is passed, all values of the top level mapping must be mappings)r�r3r�r�zASeries.replace cannot use dict-like to_replace and non-None valuez.value argument must be scalar, dict, or Seriesz2Replacement lists must match in length. Expecting z got r�)�src_list�	dest_listr�r�z|'regex' must be a string or a compiled regular expression or a list or dict of strings or regular expressions, you passed a z<Series.replace cannot use dict-value and non-None to_replace)r,r�r�zInvalid "to_replace" type: r�r�ra)7rr�r�r�rr�rcrUrargrfrcr��reprrXrGrr	r
rHrPrLrCr�rlrRrQr_rrJr%rkr�r�r��_replace_singler�r:r�r�r�rQr�r��_replace_columnwiserr�r��replace_listrx�
replace_regexr�r�r�r�)r�r,r�r�r3r�rbr
rr�rvr�r�r�r5�are_mappings�to_rep_dict�
value_dictr4r�rl�to_repr��vals                        r�r�zNDFrame.replace�s�� ����'��M�M�*�4��:�+>�+>�*?�@F�F��+�-�
��
��M�M�)�$�t�*�*=�*=�)>�?F�F��+�-�
�
�S�^�^�#��#�.�.�(� ��,����
�M�M���:�&�&�'�(=�=��+�-�
�
�j�!��
�+��J�'��2���Z�(�1�1�2�3�5��
�&�g�y�9����/�1��?�?�4�(�I�5��M�M�6�.�#$���+�-��1�1�3��o�o�d�+��%�	��d�I�.�=��3F���N�I��)�#��M�M�>�%�#$���u�~�*�"8��S�T�T��C�N�N�"�f�C�N�N�&B�
����'��� �
�+�L��4G�(�\�
��*�u�d�m�4��d�L�1�-�!�Z�Z��.�.�(�&�'�5�A�(��F��#�!�M��+�+�J����O�O��
�+�#�E�*�#�2���
#�
�����)�)�+�,�E��"�E�{���f�!#�B�f��5;�<�V��L��O�V�L�<��<� ��<�(�#�D���
!���
�!�D�A�q�$(��Q�W�W�Y��#8�$���=�L�D�&�
&*�$�Z�K��N�$(��L�J�q�M�"�%0��E�
�$(�&�E�
��<�<��E�7�%�u� ��
�
�9�9����y�y�d�y�+�+��J�'���&�
$.�?�?�#4��#4�C��%�*�*�,�.�3�$�;��j��o�u�S�z�:�:�#4���
 �3�3�G�W�e�L�L�&�e�,��y�y�A�~�(�1���
AK�@P�@P�@R��@R���f��f�e�_�,�@R��� �3�3�G�W�e�L�L�#�$T�U�U��j�)�#�E�*�#�G�c�*�o�5�E��z�?�c�%�j�0�$�%�%(��_�$5�U�3�u�:�,�a�I��� �9�9�1�1�'�#�#��	2����#�$�U�+�#�E�*�#�E�*�#�(�(,�T�%�[�-A�-A�(B�'C�E���
�|�|��5�'��d�$���
 ��&��y�y�A�~�(�2���GL�k�k�m�T�m�(�#�s�s�Z��$5�5�m�G�T��3�3�G�W�e�L�L�%�e�,�,�U�J�?�E��#'�9�9�#:�#:�'1�"'�$+�$;�$��$(�9�9�#4�#4�'1���$5�$��$�5�d�4�
�;K�;T�;T�6U�5V�W����+�+�H�8�=�=�+�I����'�'��/�/��&�&�t�I�&�>�>��C=��R����bUs�[�2([!�'[&�3[,)r�r3r��limit_directionr�r�c��yr�rt�	r�rbr�r3r�r<r�r�rs	         r��interpolatezNDFrame.interpolate����	r�)r�r3r<r�r�c��yr�rtr>s	         r�r?zNDFrame.interpolate�r@r�c��yr�rtr>s	         r�r?zNDFrame.interpolate�r@r�c��|tjur<tjdt	|�j
�d�tt���nd}|�|dk7rtd��t|d�}|r�tsGt�r=tj|�tkr�tjtt d��n�tszt�sp|j#�r`tj|�}	t}
t%|t&�rt)|�r|
d	z
}
|	|
kr tjt*td��|j-|�}|j.r|ry|j1�St%|t2�std
��gd�}|j5�|vrBtjt	|�j
�d|�d
�tt���|d}
}n�|d	k(r|j6dfn|df\}}
t9j:|j<t>k(�ro|j@dk(r&t9jB|j<t>k(�s:tjt	|�j
�d�tt���||vr(d|vr$tdt	|�j
�d|����t%|jDtF�r|dk7rtd��tIjJ||�}|j@dk(r1t9jB|j<t>k(�rtMd��|j5�|vrk|jNjPs$|d	k(r|r
tS��|j6d	|z
d}
}}|jNjU||jW|�||||��}nDtIjX||jD�}|jNjZd|||||||d�|��}|j]||j^��}|
r|j6}|r|ja|�S|jc|d��S)a�
        Fill NaN values using an interpolation method.

        Please note that only ``method='linear'`` is supported for
        DataFrame/Series with a MultiIndex.

        Parameters
        ----------
        method : str, default 'linear'
            Interpolation technique to use. One of:

            * 'linear': Ignore the index and treat the values as equally
              spaced. This is the only method supported on MultiIndexes.
            * 'time': Works on daily and higher resolution data to interpolate
              given length of interval.
            * 'index', 'values': use the actual numerical values of the index.
            * 'pad': Fill in NaNs using existing values.
            * 'nearest', 'zero', 'slinear', 'quadratic', 'cubic',
              'barycentric', 'polynomial': Passed to
              `scipy.interpolate.interp1d`, whereas 'spline' is passed to
              `scipy.interpolate.UnivariateSpline`. These methods use the numerical
              values of the index.  Both 'polynomial' and 'spline' require that
              you also specify an `order` (int), e.g.
              ``df.interpolate(method='polynomial', order=5)``. Note that,
              `slinear` method in Pandas refers to the Scipy first order `spline`
              instead of Pandas first order `spline`.
            * 'krogh', 'piecewise_polynomial', 'spline', 'pchip', 'akima',
              'cubicspline': Wrappers around the SciPy interpolation methods of
              similar names. See `Notes`.
            * 'from_derivatives': Refers to
              `scipy.interpolate.BPoly.from_derivatives`.

        axis : {{0 or 'index', 1 or 'columns', None}}, default None
            Axis to interpolate along. For `Series` this parameter is unused
            and defaults to 0.
        limit : int, optional
            Maximum number of consecutive NaNs to fill. Must be greater than
            0.
        inplace : bool, default False
            Update the data in place if possible.
        limit_direction : {{'forward', 'backward', 'both'}}, Optional
            Consecutive NaNs will be filled in this direction.

            If limit is specified:
                * If 'method' is 'pad' or 'ffill', 'limit_direction' must be 'forward'.
                * If 'method' is 'backfill' or 'bfill', 'limit_direction' must be
                  'backwards'.

            If 'limit' is not specified:
                * If 'method' is 'backfill' or 'bfill', the default is 'backward'
                * else the default is 'forward'

            raises ValueError if `limit_direction` is 'forward' or 'both' and
                method is 'backfill' or 'bfill'.
            raises ValueError if `limit_direction` is 'backward' or 'both' and
                method is 'pad' or 'ffill'.

        limit_area : {{`None`, 'inside', 'outside'}}, default None
            If limit is specified, consecutive NaNs will be filled with this
            restriction.

            * ``None``: No fill restriction.
            * 'inside': Only fill NaNs surrounded by valid values
              (interpolate).
            * 'outside': Only fill NaNs outside valid values (extrapolate).

        downcast : optional, 'infer' or None, defaults to None
            Downcast dtypes if possible.

            .. deprecated:: 2.1.0

        ``**kwargs`` : optional
            Keyword arguments to pass on to the interpolating function.

        Returns
        -------
        Series or DataFrame or None
            Returns the same object type as the caller, interpolated at
            some or all ``NaN`` values or None if ``inplace=True``.

        See Also
        --------
        fillna : Fill missing values using different methods.
        scipy.interpolate.Akima1DInterpolator : Piecewise cubic polynomials
            (Akima interpolator).
        scipy.interpolate.BPoly.from_derivatives : Piecewise polynomial in the
            Bernstein basis.
        scipy.interpolate.interp1d : Interpolate a 1-D function.
        scipy.interpolate.KroghInterpolator : Interpolate polynomial (Krogh
            interpolator).
        scipy.interpolate.PchipInterpolator : PCHIP 1-d monotonic cubic
            interpolation.
        scipy.interpolate.CubicSpline : Cubic spline data interpolator.

        Notes
        -----
        The 'krogh', 'piecewise_polynomial', 'spline', 'pchip' and 'akima'
        methods are wrappers around the respective SciPy implementations of
        similar names. These use the actual numerical values of the index.
        For more information on their behavior, see the
        `SciPy documentation
        <https://docs.scipy.org/doc/scipy/reference/interpolate.html#univariate-interpolation>`__.

        Examples
        --------
        Filling in ``NaN`` in a :class:`~pandas.Series` via linear
        interpolation.

        >>> s = pd.Series([0, 1, np.nan, 3])
        >>> s
        0    0.0
        1    1.0
        2    NaN
        3    3.0
        dtype: float64
        >>> s.interpolate()
        0    0.0
        1    1.0
        2    2.0
        3    3.0
        dtype: float64

        Filling in ``NaN`` in a Series via polynomial interpolation or splines:
        Both 'polynomial' and 'spline' methods require that you also specify
        an ``order`` (int).

        >>> s = pd.Series([0, 2, np.nan, 8])
        >>> s.interpolate(method='polynomial', order=2)
        0    0.000000
        1    2.000000
        2    4.666667
        3    8.000000
        dtype: float64

        Fill the DataFrame forward (that is, going down) along each column
        using linear interpolation.

        Note how the last entry in column 'a' is interpolated differently,
        because there is no entry after it to use for interpolation.
        Note how the first entry in column 'b' remains ``NaN``, because there
        is no entry before it to use for interpolation.

        >>> df = pd.DataFrame([(0.0, np.nan, -1.0, 1.0),
        ...                    (np.nan, 2.0, np.nan, np.nan),
        ...                    (2.0, 3.0, np.nan, 9.0),
        ...                    (np.nan, 4.0, -4.0, 16.0)],
        ...                   columns=list('abcd'))
        >>> df
             a    b    c     d
        0  0.0  NaN -1.0   1.0
        1  NaN  2.0  NaN   NaN
        2  2.0  3.0  NaN   9.0
        3  NaN  4.0 -4.0  16.0
        >>> df.interpolate(method='linear', limit_direction='forward', axis=0)
             a    b    c     d
        0  0.0  NaN -1.0   1.0
        1  1.0  2.0 -2.0   5.0
        2  2.0  3.0 -3.0   9.0
        3  2.0  4.0 -4.0  16.0

        Using polynomial interpolation.

        >>> df['d'].interpolate(method='polynomial', order=2)
        0     1.0
        1     4.0
        2     9.0
        3    16.0
        Name: d, dtype: float64
        r�z�.interpolate is deprecated and will be removed in a future version. Call result.infer_objects(copy=False) on the result instead.r�Nr\z'downcast must be either None or 'infer'r�rr�z&'method' should be a string, not None.)rr$r!r)z.interpolate with method=zZ is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead.FTz�.interpolate with object dtype is deprecated and will raise in a future version. Call obj.infer_objects(copy=False) before interpolating instead.roz('fill_value' is not a valid keyword for z.interpolate with method from �linearz@Only `method=linear` interpolation is supported on MultiIndexes.zvCannot interpolate with all object-dtype columns in the DataFrame. Try setting at least one column to a numeric dtype.r�)rbrr3r<r�r�r�r�r?rart)2rr�r�r�rr�rcrUrrXrGrr	r
rHrPrLrCr�rlrRrQrrr�r��lowerr=rOr�r<r�rr�rrru�infer_limit_directionr�r�rgr�rr��get_interp_indexr?r�r�r�r�)r�rbr�r3r�r<r�r�rr
r�fillna_methodsr��should_transposer�rrvs                 r�r?zNDFrame.interpolate s���l�3�>�>�)��M�M�,�T�$�Z�-@�-@�,A�BO�O��+�-�
��H���H��$7��F�G�G�%�g�y�9����/�1��?�?�4�(�I�5��M�M�6�.�#$���+�-��1�1�3��o�o�d�+��%�	��d�I�.�=��3F���N�I��)�#��M�M�>�%�#$���$�$�T�*���:�:����9�9�;���&�#�&��E�F�F�>���<�<�>�^�+��M�M���:�&�&�'�'@���I:�:��+�-�
�%)�%�!�C�6:�a�i�T�V�V�T�N�d�E�]�!�C�!��v�v�c�j�j�F�*�+����A�
�"�&�&����v�1E�*F��M�M���:�.�.�/�0V�V�&�#3�#5���^�#���(>��:���:�&�&�'�'E�!�"�$��
��c�i�i��,��8�1C��R��
�"�7�7���P���8�8�q�=�R�V�V�C�J�J�&�$8�9��-��
��<�<�>�^�+��9�9�,�,�����-�/�/�.2�f�f�a�$�h��+�T���x�x�/�/���1�1�$�7��%��!�
0��H��,�,�V�S�Y�Y�?�E�+�s�x�x�+�+�	���� /�%��!�	��	�H��+�+�H�8�=�=�+�I����X�X�F���'�'��/�/��&�&�t�M�&�B�Br�c�2�t|t�rt|�}|jjstd��t|t�}|r
|�'td��|�|j}t|�s|g}t|�}|s�|jd}t|jt�r!t||jj��}||kr>|s,|j|j|tj��StjS|rd|jj!|d��}|dkDr|dz}|j"}|dkDr't%||�r|dz}|dkDrt%||�r�||St|t&�s|rt'|�nt'|g�}|r|j%�n"||j%�j)d�	�}|j+�r�|r8t-d
|�}|j/tj||j0��S|r8t-d|�}|j/tj||j�
�St-d|�}|jtj|j|d��S|jj3||j"�}	|	dk(}
|j5|	�}||_|
j)�rtj|j6|
<|r|S|j8dS)ad
        Return the last row(s) without any NaNs before `where`.

        The last row (for each element in `where`, if list) without any
        NaN is taken.
        In case of a :class:`~pandas.DataFrame`, the last row without NaN
        considering only the subset of columns (if not `None`)

        If there is no good value, NaN is returned for a Series or
        a Series of NaN values for a DataFrame

        Parameters
        ----------
        where : date or array-like of dates
            Date(s) before which the last row(s) are returned.
        subset : str or array-like of str, default `None`
            For DataFrame, if not `None`, only use these columns to
            check for NaNs.

        Returns
        -------
        scalar, Series, or DataFrame

            The return can be:

            * scalar : when `self` is a Series and `where` is a scalar
            * Series: when `self` is a Series and `where` is an array-like,
              or when `self` is a DataFrame and `where` is a scalar
            * DataFrame : when `self` is a DataFrame and `where` is an
              array-like

        See Also
        --------
        merge_asof : Perform an asof merge. Similar to left join.

        Notes
        -----
        Dates are assumed to be sorted. Raises if this is not the case.

        Examples
        --------
        A Series and a scalar `where`.

        >>> s = pd.Series([1, 2, np.nan, 4], index=[10, 20, 30, 40])
        >>> s
        10    1.0
        20    2.0
        30    NaN
        40    4.0
        dtype: float64

        >>> s.asof(20)
        2.0

        For a sequence `where`, a Series is returned. The first value is
        NaN, because the first element of `where` is before the first
        index value.

        >>> s.asof([5, 20])
        5     NaN
        20    2.0
        dtype: float64

        Missing values are not considered. The following is ``2.0``, not
        NaN, even though NaN is at the index location for ``30``.

        >>> s.asof(30)
        2.0

        Take all columns into consideration

        >>> df = pd.DataFrame({'a': [10., 20., 30., 40., 50.],
        ...                    'b': [None, None, None, None, 500]},
        ...                   index=pd.DatetimeIndex(['2018-02-27 09:01:00',
        ...                                           '2018-02-27 09:02:00',
        ...                                           '2018-02-27 09:03:00',
        ...                                           '2018-02-27 09:04:00',
        ...                                           '2018-02-27 09:05:00']))
        >>> df.asof(pd.DatetimeIndex(['2018-02-27 09:03:30',
        ...                           '2018-02-27 09:04:30']))
                              a   b
        2018-02-27 09:03:30 NaN NaN
        2018-02-27 09:04:30 NaN NaN

        Take a single column into consideration

        >>> df.asof(pd.DatetimeIndex(['2018-02-27 09:03:30',
        ...                           '2018-02-27 09:04:30']),
        ...         subset=['a'])
                                a   b
        2018-02-27 09:03:30  30.0 NaN
        2018-02-27 09:04:30  40.0 NaN
        zasof requires a sorted indexzsubset is not valid for Seriesr)�freq)rr(r��right��sider�r�r�)rr(r�r�r�)r�r�rr�is_monotonic_increasingrrlrrcr�rrKr�rO�float64�nan�searchsortedrfror~r�r�r
r�r(�	asof_locsr�rr|)r�rr��	is_series�is_listr�rr��nullsrrLr�s            r��asofzNDFrame.asofI!s���~�e�S�!��e�$�E��z�z�1�1��;�<�<��t�Y�/�	���!� �!A�B�B��~�������'� ����u�%����J�J�q�M�E��$�*�*�k�2��u�4�:�:�?�?�;���u�}� ��3�3�"�l�l��b�j�j�4����v�v�
���j�j�-�-�e�'�-�B����7��1�H�C������A�g�$�v�c�{�"3��1�H�C��A�g�$�v�c�{�"3��c�{�"��%��'�$+�E�%�L���w��E�(��	�	��d�6�l�.?�.?�.A�.E�.E�1�.E�.M���9�9�;���H�d�+���(�(����u�4�9�9�(�M�M���K��.���(�(����u�d�l�l�(�S�S��K��.���/�/��F�F�$�,�,�U�1�X�0����z�z�#�#�E�U�]�]�+;�<���r�z���y�y������
��8�8�:� �V�V�D�H�H�T�N��t�1�D�I�I�b�M�1r�c�:�t|�j|d��S)ah
        Detect missing values.

        Return a boolean same-sized object indicating if the values are NA.
        NA values, such as None or :attr:`numpy.NaN`, gets mapped to True
        values.
        Everything else gets mapped to False values. Characters such as empty
        strings ``''`` or :attr:`numpy.inf` are not considered NA values
        (unless you set ``pandas.options.mode.use_inf_as_na = True``).

        Returns
        -------
        {klass}
            Mask of bool values for each element in {klass} that
            indicates whether an element is an NA value.

        See Also
        --------
        {klass}.isnull : Alias of isna.
        {klass}.notna : Boolean inverse of isna.
        {klass}.dropna : Omit axes labels with missing values.
        isna : Top-level isna.

        Examples
        --------
        Show which entries in a DataFrame are NA.

        >>> df = pd.DataFrame(dict(age=[5, 6, np.nan],
        ...                        born=[pd.NaT, pd.Timestamp('1939-05-27'),
        ...                              pd.Timestamp('1940-04-25')],
        ...                        name=['Alfred', 'Batman', ''],
        ...                        toy=[None, 'Batmobile', 'Joker']))
        >>> df
           age       born    name        toy
        0  5.0        NaT  Alfred       None
        1  6.0 1939-05-27  Batman  Batmobile
        2  NaN 1940-04-25              Joker

        >>> df.isna()
             age   born   name    toy
        0  False   True  False   True
        1  False  False  False  False
        2   True  False  False  False

        Show which entries in a Series are NA.

        >>> ser = pd.Series([5, 6, np.nan])
        >>> ser
        0    5.0
        1    6.0
        2    NaN
        dtype: float64

        >>> ser.isna()
        0    False
        1    False
        2     True
        dtype: bool
        rora�ror�r�s r�rozNDFrame.isna�!s��z�D�z�&�&�t�F�&�;�;r�c�:�t|�j|d��S)N�isnullrarYr�s r�r[zNDFrame.isnull4"s���D�z�&�&�t�H�&�=�=r�c�:�t|�j|d��S)a�
        Detect existing (non-missing) values.

        Return a boolean same-sized object indicating if the values are not NA.
        Non-missing values get mapped to True. Characters such as empty
        strings ``''`` or :attr:`numpy.inf` are not considered NA values
        (unless you set ``pandas.options.mode.use_inf_as_na = True``).
        NA values, such as None or :attr:`numpy.NaN`, get mapped to False
        values.

        Returns
        -------
        {klass}
            Mask of bool values for each element in {klass} that
            indicates whether an element is not an NA value.

        See Also
        --------
        {klass}.notnull : Alias of notna.
        {klass}.isna : Boolean inverse of notna.
        {klass}.dropna : Omit axes labels with missing values.
        notna : Top-level notna.

        Examples
        --------
        Show which entries in a DataFrame are not NA.

        >>> df = pd.DataFrame(dict(age=[5, 6, np.nan],
        ...                        born=[pd.NaT, pd.Timestamp('1939-05-27'),
        ...                              pd.Timestamp('1940-04-25')],
        ...                        name=['Alfred', 'Batman', ''],
        ...                        toy=[None, 'Batmobile', 'Joker']))
        >>> df
           age       born    name        toy
        0  5.0        NaT  Alfred       None
        1  6.0 1939-05-27  Batman  Batmobile
        2  NaN 1940-04-25              Joker

        >>> df.notna()
             age   born  name    toy
        0   True  False  True  False
        1   True   True  True   True
        2  False   True  True   True

        Show which entries in a Series are not NA.

        >>> ser = pd.Series([5, 6, np.nan])
        >>> ser
        0    5.0
        1    6.0
        2    NaN
        dtype: float64

        >>> ser.notna()
        0     True
        1     True
        2    False
        dtype: bool
        rpra�rpr�r�s r�rpz
NDFrame.notna8"s��z�T�{�'�'��W�'�=�=r�c�:�t|�j|d��S)N�notnullrar]r�s r�r_zNDFrame.notnullw"s���T�{�'�'��Y�'�?�?r�c�D�|�tjt|��s |�)tjt|��rtd��|}|j�}|�|||k\z}|j	|||��}|�"|||kz}|r|n|}|j	|||��}|S)Nz*Cannot use an NA value as a clip threshold�r�)rOr�rorr)r�rE�upperr�rvrL�conds       r��_clip_with_scalarzNDFrame._clip_with_scalar{"s�����"�&�&��e��"5���"�&�&��e��"5��I�J�J����y�y�{�����4�5�=�)�D��\�\��e�W�"��F����4�5�=�)�D�$�T�&�F��\�\��e�W�"��F��
r�c�v�|�|j|�}t|�rBt|�r7|jdk(r|j	d||��S|j	|d|��St|t�sPt|�rEt|t�r|j||j��}n|j||d��d}t|�rB|jdk(rtjntj}|j|�}n|}|||��t|�z}|j||||��S)N�lera)r)�flexr�r�r�)rrgrdr�rdr�rlrcr�r�
_align_for_oprO�infr�ror)r��	thresholdrbr�r�ro�
threshold_infr�s        r��_clip_with_one_boundzNDFrame._clip_with_one_bound�"s �����(�(��.�D��Y��I�i�$8����$�&��-�-�d�I�w�-�O�O��)�)�)�T�7�)�K�K�
�9�i�0�l�9�6M��$�	�*� �-�-�i�t�z�z�-�J�	� �.�.�y�$�T�.�J�1�M�	��	�"�#)�?�?�d�#:��������J�%�,�,�Z�8�M�%�M��
�D�1�D��J�>���z�z�&�)�$��z�H�Hr�r�c��yr�rt�r�rErbr�r�rs      r��clipzNDFrame.clip�"rr�r�c��yr�rtrns      r�rozNDFrame.clip�"rr�c��yr�rtrns      r�rozNDFrame.clip�"rr�c�v�t|d�}|r�tsGt�r=tj|�t
kr�t
jttd��n�ts{t�sq|j�ratj|�}t
}t|t�rt|d�r|dz
}||kr t
jttd��t!j"|d|�}|�|j%|�}t'|�}t)|�st+j,|�rd}nt+j.|�rd}t'|�}	t)|�st+j,|	�rd}nt+j.|	�rd}|�0|�.t1|�r#t1|�rt3||�t5||�}}|�t7|�r!|�t7|�r|j9|||��S|}
|�|
j;||j<||�	�}
|�#|r|}
|
j;||j>||�	�}
|
S)
a�
        Trim values at input threshold(s).

        Assigns values outside boundary to boundary values. Thresholds
        can be singular values or array like, and in the latter case
        the clipping is performed element-wise in the specified axis.

        Parameters
        ----------
        lower : float or array-like, default None
            Minimum threshold value. All values below this
            threshold will be set to it. A missing
            threshold (e.g `NA`) will not clip the value.
        upper : float or array-like, default None
            Maximum threshold value. All values above this
            threshold will be set to it. A missing
            threshold (e.g `NA`) will not clip the value.
        axis : {{0 or 'index', 1 or 'columns', None}}, default None
            Align object with lower and upper along the given axis.
            For `Series` this parameter is unused and defaults to `None`.
        inplace : bool, default False
            Whether to perform the operation in place on the data.
        *args, **kwargs
            Additional keywords have no effect but might be accepted
            for compatibility with numpy.

        Returns
        -------
        Series or DataFrame or None
            Same type as calling object with the values outside the
            clip boundaries replaced or None if ``inplace=True``.

        See Also
        --------
        Series.clip : Trim values at input threshold in series.
        DataFrame.clip : Trim values at input threshold in dataframe.
        numpy.clip : Clip (limit) the values in an array.

        Examples
        --------
        >>> data = {'col_0': [9, -3, 0, -1, 5], 'col_1': [-2, -7, 6, 8, -5]}
        >>> df = pd.DataFrame(data)
        >>> df
           col_0  col_1
        0      9     -2
        1     -3     -7
        2      0      6
        3     -1      8
        4      5     -5

        Clips per column using lower and upper thresholds:

        >>> df.clip(-4, 6)
           col_0  col_1
        0      6     -2
        1     -3     -4
        2      0      6
        3     -1      6
        4      5     -4

        Clips using specific lower and upper thresholds per column:

        >>> df.clip([-2, -1], [4, 5])
            col_0  col_1
        0      4     -1
        1     -2     -1
        2      0      5
        3     -1      5
        4      4     -1

        Clips using specific lower and upper thresholds per column element:

        >>> t = pd.Series([2, -4, -1, 6, 3])
        >>> t
        0    2
        1   -4
        2   -1
        3    6
        4    3
        dtype: int64

        >>> df.clip(t, t + 4, axis=0)
           col_0  col_1
        0      6      2
        1     -3     -4
        2      0      3
        3      6      8
        4      5      3

        Clips using specific lower threshold per column element, with missing values:

        >>> t = pd.Series([2, -4, np.nan, 6, 3])
        >>> t
        0    2.0
        1   -4.0
        2    NaN
        3    6.0
        4    3.0
        dtype: float64

        >>> df.clip(t, axis=0)
        col_0  col_1
        0      9      2
        1     -3     -4
        2      0      6
        3      6      8
        4      5      3
        r�rr�r�r�rtNra)rbr�r�) rXrGrr	r
rHr�r�rPrLrCr�rl�hasattrrQrcr��validate_clip_with_axisrrorcrOr�r�rg�min�maxrdrdrl�gerf)r�rErbr�r�rr
r�
isna_lower�
isna_upperrvs           r�rozNDFrame.clip�"s��l&�g�y�9����/�1��?�?�4�(�I�5��M�M�6�.�#$���+�-��1�1�3��o�o�d�+��%�	��d�I�.�7�4��3K���N�I��)�#��M�M�>�%�#$���)�)�$��F�;�����(�(��.�D��%�[�
��E�"��v�v�j�!���
�V�V�J�
��E��%�[�
��E�"��v�v�j�!���
�V�V�J�
��E�
���!��%� ��%� ��u�e�,�c�%��.?�5�E�
�M�Y�u�-�E�M�Y�u�EU��)�)�%���)�H�H������0�0��d�g�g�D�'�1��F�������0�0��d�g�g�D�'�1��F��
r�c�*�ddlm}|||||||��S)a�
        Convert time series to specified frequency.

        Returns the original data conformed to a new index with the specified
        frequency.

        If the index of this {klass} is a :class:`~pandas.PeriodIndex`, the new index
        is the result of transforming the original index with
        :meth:`PeriodIndex.asfreq <pandas.PeriodIndex.asfreq>` (so the original index
        will map one-to-one to the new index).

        Otherwise, the new index will be equivalent to ``pd.date_range(start, end,
        freq=freq)`` where ``start`` and ``end`` are, respectively, the first and
        last entries in the original index (see :func:`pandas.date_range`). The
        values corresponding to any timesteps in the new index which were not present
        in the original index will be null (``NaN``), unless a method for filling
        such unknowns is provided (see the ``method`` parameter below).

        The :meth:`resample` method is more appropriate if an operation on each group of
        timesteps (such as an aggregate) is necessary to represent the data at the new
        frequency.

        Parameters
        ----------
        freq : DateOffset or str
            Frequency DateOffset or string.
        method : {{'backfill'/'bfill', 'pad'/'ffill'}}, default None
            Method to use for filling holes in reindexed Series (note this
            does not fill NaNs that already were present):

            * 'pad' / 'ffill': propagate last valid observation forward to next
              valid
            * 'backfill' / 'bfill': use NEXT valid observation to fill.
        how : {{'start', 'end'}}, default end
            For PeriodIndex only (see PeriodIndex.asfreq).
        normalize : bool, default False
            Whether to reset output index to midnight.
        fill_value : scalar, optional
            Value to use for missing values, applied during upsampling (note
            this does not fill NaNs that already were present).

        Returns
        -------
        {klass}
            {klass} object reindexed to the specified frequency.

        See Also
        --------
        reindex : Conform DataFrame to new index with optional filling logic.

        Notes
        -----
        To learn more about the frequency strings, please see `this link
        <https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases>`__.

        Examples
        --------
        Start by creating a series with 4 one minute timestamps.

        >>> index = pd.date_range('1/1/2000', periods=4, freq='min')
        >>> series = pd.Series([0.0, None, 2.0, 3.0], index=index)
        >>> df = pd.DataFrame({{'s': series}})
        >>> df
                               s
        2000-01-01 00:00:00    0.0
        2000-01-01 00:01:00    NaN
        2000-01-01 00:02:00    2.0
        2000-01-01 00:03:00    3.0

        Upsample the series into 30 second bins.

        >>> df.asfreq(freq='30s')
                               s
        2000-01-01 00:00:00    0.0
        2000-01-01 00:00:30    NaN
        2000-01-01 00:01:00    NaN
        2000-01-01 00:01:30    NaN
        2000-01-01 00:02:00    2.0
        2000-01-01 00:02:30    NaN
        2000-01-01 00:03:00    3.0

        Upsample again, providing a ``fill value``.

        >>> df.asfreq(freq='30s', fill_value=9.0)
                               s
        2000-01-01 00:00:00    0.0
        2000-01-01 00:00:30    9.0
        2000-01-01 00:01:00    NaN
        2000-01-01 00:01:30    9.0
        2000-01-01 00:02:00    2.0
        2000-01-01 00:02:30    9.0
        2000-01-01 00:03:00    3.0

        Upsample again, providing a ``method``.

        >>> df.asfreq(freq='30s', method='bfill')
                               s
        2000-01-01 00:00:00    0.0
        2000-01-01 00:00:30    NaN
        2000-01-01 00:01:00    NaN
        2000-01-01 00:01:30    2.0
        2000-01-01 00:02:00    2.0
        2000-01-01 00:02:30    3.0
        2000-01-01 00:03:00    3.0
        r)�asfreq)rb�how�	normalizero)�pandas.core.resampler{)r�rKrbr|r}ror{s       r�r{zNDFrame.asfreq�#s'��f	0�������!�

�	
r�c���|�d}|j|�}|j|�}t|t�st	d��|j||��}|j
||��S)a'
        Select values at particular time of day (e.g., 9:30AM).

        Parameters
        ----------
        time : datetime.time or str
            The values to select.
        axis : {0 or 'index', 1 or 'columns'}, default 0
            For `Series` this parameter is unused and defaults to 0.

        Returns
        -------
        Series or DataFrame

        Raises
        ------
        TypeError
            If the index is not  a :class:`DatetimeIndex`

        See Also
        --------
        between_time : Select values between particular times of the day.
        first : Select initial periods of time series based on a date offset.
        last : Select final periods of time series based on a date offset.
        DatetimeIndex.indexer_at_time : Get just the index locations for
            values at particular time of the day.

        Examples
        --------
        >>> i = pd.date_range('2018-04-09', periods=4, freq='12h')
        >>> ts = pd.DataFrame({'A': [1, 2, 3, 4]}, index=i)
        >>> ts
                             A
        2018-04-09 00:00:00  1
        2018-04-09 12:00:00  2
        2018-04-10 00:00:00  3
        2018-04-10 12:00:00  4

        >>> ts.at_time('12:00')
                             A
        2018-04-09 12:00:00  2
        2018-04-10 12:00:00  4
        r�Index must be DatetimeIndex)rWr�)rr
r�r}r��indexer_at_timer�)r��timerWr�rr�s      r��at_timezNDFrame.at_time$sn��Z�<��D��$�$�T�*�����t�$���%��/��9�:�:��'�'��4�'�8���&�&�w�T�&�:�:r�c���|�d}|j|�}|j|�}t|t�st	d��t|�\}}|j
||||��}|j||��S)a]
        Select values between particular times of the day (e.g., 9:00-9:30 AM).

        By setting ``start_time`` to be later than ``end_time``,
        you can get the times that are *not* between the two times.

        Parameters
        ----------
        start_time : datetime.time or str
            Initial time as a time filter limit.
        end_time : datetime.time or str
            End time as a time filter limit.
        inclusive : {"both", "neither", "left", "right"}, default "both"
            Include boundaries; whether to set each bound as closed or open.
        axis : {0 or 'index', 1 or 'columns'}, default 0
            Determine range time on index or columns value.
            For `Series` this parameter is unused and defaults to 0.

        Returns
        -------
        Series or DataFrame
            Data from the original object filtered to the specified dates range.

        Raises
        ------
        TypeError
            If the index is not  a :class:`DatetimeIndex`

        See Also
        --------
        at_time : Select values at a particular time of the day.
        first : Select initial periods of time series based on a date offset.
        last : Select final periods of time series based on a date offset.
        DatetimeIndex.indexer_between_time : Get just the index locations for
            values between particular times of the day.

        Examples
        --------
        >>> i = pd.date_range('2018-04-09', periods=4, freq='1D20min')
        >>> ts = pd.DataFrame({'A': [1, 2, 3, 4]}, index=i)
        >>> ts
                             A
        2018-04-09 00:00:00  1
        2018-04-10 00:20:00  2
        2018-04-11 00:40:00  3
        2018-04-12 01:00:00  4

        >>> ts.between_time('0:15', '0:45')
                             A
        2018-04-10 00:20:00  2
        2018-04-11 00:40:00  3

        You get the times that are *not* between two times by setting
        ``start_time`` later than ``end_time``:

        >>> ts.between_time('0:45', '0:15')
                             A
        2018-04-09 00:00:00  1
        2018-04-12 01:00:00  4
        rr�)�
include_start�include_endr�)rr
r�r}r�rZ�indexer_between_timer�)	r��
start_time�end_time�	inclusiver�r�left_inclusive�right_inclusiver�s	         r��between_timezNDFrame.between_timeQ$s���H�<��D��$�$�T�*�����t�$���%��/��9�:�:�*<�Y�*G�'����,�,���(�'�	-�
���&�&�w�T�&�:�:r��	start_dayc��ddlm}|tjurw|j	|�}|dk(r%tjdtt���n>tjdt|�j�d�tt���nd}|tjur<tjdt|�j�d	�tt���nd
}|tjur<tjdt|�j�d�tt���nd
}|td|�|||||||||	|
|��S)a�1
        Resample time-series data.

        Convenience method for frequency conversion and resampling of time series.
        The object must have a datetime-like index (`DatetimeIndex`, `PeriodIndex`,
        or `TimedeltaIndex`), or the caller must pass the label of a datetime-like
        series/index to the ``on``/``level`` keyword parameter.

        Parameters
        ----------
        rule : DateOffset, Timedelta or str
            The offset string or object representing target conversion.
        axis : {{0 or 'index', 1 or 'columns'}}, default 0
            Which axis to use for up- or down-sampling. For `Series` this parameter
            is unused and defaults to 0. Must be
            `DatetimeIndex`, `TimedeltaIndex` or `PeriodIndex`.

            .. deprecated:: 2.0.0
                Use frame.T.resample(...) instead.
        closed : {{'right', 'left'}}, default None
            Which side of bin interval is closed. The default is 'left'
            for all frequency offsets except for 'ME', 'YE', 'QE', 'BME',
            'BA', 'BQE', and 'W' which all have a default of 'right'.
        label : {{'right', 'left'}}, default None
            Which bin edge label to label bucket with. The default is 'left'
            for all frequency offsets except for 'ME', 'YE', 'QE', 'BME',
            'BA', 'BQE', and 'W' which all have a default of 'right'.
        convention : {{'start', 'end', 's', 'e'}}, default 'start'
            For `PeriodIndex` only, controls whether to use the start or
            end of `rule`.

            .. deprecated:: 2.2.0
                Convert PeriodIndex to DatetimeIndex before resampling instead.
        kind : {{'timestamp', 'period'}}, optional, default None
            Pass 'timestamp' to convert the resulting index to a
            `DateTimeIndex` or 'period' to convert it to a `PeriodIndex`.
            By default the input representation is retained.

            .. deprecated:: 2.2.0
                Convert index to desired type explicitly instead.

        on : str, optional
            For a DataFrame, column to use instead of index for resampling.
            Column must be datetime-like.
        level : str or int, optional
            For a MultiIndex, level (name or number) to use for
            resampling. `level` must be datetime-like.
        origin : Timestamp or str, default 'start_day'
            The timestamp on which to adjust the grouping. The timezone of origin
            must match the timezone of the index.
            If string, must be one of the following:

            - 'epoch': `origin` is 1970-01-01
            - 'start': `origin` is the first value of the timeseries
            - 'start_day': `origin` is the first day at midnight of the timeseries

            - 'end': `origin` is the last value of the timeseries
            - 'end_day': `origin` is the ceiling midnight of the last day

            .. versionadded:: 1.3.0

            .. note::

                Only takes effect for Tick-frequencies (i.e. fixed frequencies like
                days, hours, and minutes, rather than months or quarters).
        offset : Timedelta or str, default is None
            An offset timedelta added to the origin.

        group_keys : bool, default False
            Whether to include the group keys in the result index when using
            ``.apply()`` on the resampled object.

            .. versionadded:: 1.5.0

                Not specifying ``group_keys`` will retain values-dependent behavior
                from pandas 1.4 and earlier (see :ref:`pandas 1.5.0 Release notes
                <whatsnew_150.enhancements.resample_group_keys>` for examples).

            .. versionchanged:: 2.0.0

                ``group_keys`` now defaults to ``False``.

        Returns
        -------
        pandas.api.typing.Resampler
            :class:`~pandas.core.Resampler` object.

        See Also
        --------
        Series.resample : Resample a Series.
        DataFrame.resample : Resample a DataFrame.
        groupby : Group {klass} by mapping, function, label, or list of labels.
        asfreq : Reindex a {klass} with the given frequency without grouping.

        Notes
        -----
        See the `user guide
        <https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#resampling>`__
        for more.

        To learn more about the offset strings, please see `this link
        <https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#dateoffset-objects>`__.

        Examples
        --------
        Start by creating a series with 9 one minute timestamps.

        >>> index = pd.date_range('1/1/2000', periods=9, freq='min')
        >>> series = pd.Series(range(9), index=index)
        >>> series
        2000-01-01 00:00:00    0
        2000-01-01 00:01:00    1
        2000-01-01 00:02:00    2
        2000-01-01 00:03:00    3
        2000-01-01 00:04:00    4
        2000-01-01 00:05:00    5
        2000-01-01 00:06:00    6
        2000-01-01 00:07:00    7
        2000-01-01 00:08:00    8
        Freq: min, dtype: int64

        Downsample the series into 3 minute bins and sum the values
        of the timestamps falling into a bin.

        >>> series.resample('3min').sum()
        2000-01-01 00:00:00     3
        2000-01-01 00:03:00    12
        2000-01-01 00:06:00    21
        Freq: 3min, dtype: int64

        Downsample the series into 3 minute bins as above, but label each
        bin using the right edge instead of the left. Please note that the
        value in the bucket used as the label is not included in the bucket,
        which it labels. For example, in the original series the
        bucket ``2000-01-01 00:03:00`` contains the value 3, but the summed
        value in the resampled bucket with the label ``2000-01-01 00:03:00``
        does not include 3 (if it did, the summed value would be 6, not 3).

        >>> series.resample('3min', label='right').sum()
        2000-01-01 00:03:00     3
        2000-01-01 00:06:00    12
        2000-01-01 00:09:00    21
        Freq: 3min, dtype: int64

        To include this value close the right side of the bin interval,
        as shown below.

        >>> series.resample('3min', label='right', closed='right').sum()
        2000-01-01 00:00:00     0
        2000-01-01 00:03:00     6
        2000-01-01 00:06:00    15
        2000-01-01 00:09:00    15
        Freq: 3min, dtype: int64

        Upsample the series into 30 second bins.

        >>> series.resample('30s').asfreq()[0:5]   # Select first 5 rows
        2000-01-01 00:00:00   0.0
        2000-01-01 00:00:30   NaN
        2000-01-01 00:01:00   1.0
        2000-01-01 00:01:30   NaN
        2000-01-01 00:02:00   2.0
        Freq: 30s, dtype: float64

        Upsample the series into 30 second bins and fill the ``NaN``
        values using the ``ffill`` method.

        >>> series.resample('30s').ffill()[0:5]
        2000-01-01 00:00:00    0
        2000-01-01 00:00:30    0
        2000-01-01 00:01:00    1
        2000-01-01 00:01:30    1
        2000-01-01 00:02:00    2
        Freq: 30s, dtype: int64

        Upsample the series into 30 second bins and fill the
        ``NaN`` values using the ``bfill`` method.

        >>> series.resample('30s').bfill()[0:5]
        2000-01-01 00:00:00    0
        2000-01-01 00:00:30    1
        2000-01-01 00:01:00    1
        2000-01-01 00:01:30    2
        2000-01-01 00:02:00    2
        Freq: 30s, dtype: int64

        Pass a custom function via ``apply``

        >>> def custom_resampler(arraylike):
        ...     return np.sum(arraylike) + 5
        ...
        >>> series.resample('3min').apply(custom_resampler)
        2000-01-01 00:00:00     8
        2000-01-01 00:03:00    17
        2000-01-01 00:06:00    26
        Freq: 3min, dtype: int64

        For DataFrame objects, the keyword `on` can be used to specify the
        column instead of the index for resampling.

        >>> d = {{'price': [10, 11, 9, 13, 14, 18, 17, 19],
        ...      'volume': [50, 60, 40, 100, 50, 100, 40, 50]}}
        >>> df = pd.DataFrame(d)
        >>> df['week_starting'] = pd.date_range('01/01/2018',
        ...                                     periods=8,
        ...                                     freq='W')
        >>> df
           price  volume week_starting
        0     10      50    2018-01-07
        1     11      60    2018-01-14
        2      9      40    2018-01-21
        3     13     100    2018-01-28
        4     14      50    2018-02-04
        5     18     100    2018-02-11
        6     17      40    2018-02-18
        7     19      50    2018-02-25
        >>> df.resample('ME', on='week_starting').mean()
                       price  volume
        week_starting
        2018-01-31     10.75    62.5
        2018-02-28     17.00    60.0

        For a DataFrame with MultiIndex, the keyword `level` can be used to
        specify on which level the resampling needs to take place.

        >>> days = pd.date_range('1/1/2000', periods=4, freq='D')
        >>> d2 = {{'price': [10, 11, 9, 13, 14, 18, 17, 19],
        ...       'volume': [50, 60, 40, 100, 50, 100, 40, 50]}}
        >>> df2 = pd.DataFrame(
        ...     d2,
        ...     index=pd.MultiIndex.from_product(
        ...         [days, ['morning', 'afternoon']]
        ...     )
        ... )
        >>> df2
                              price  volume
        2000-01-01 morning       10      50
                   afternoon     11      60
        2000-01-02 morning        9      40
                   afternoon     13     100
        2000-01-03 morning       14      50
                   afternoon     18     100
        2000-01-04 morning       17      40
                   afternoon     19      50
        >>> df2.resample('D', level=0).sum()
                    price  volume
        2000-01-01     21     110
        2000-01-02     22     140
        2000-01-03     32     150
        2000-01-04     36      90

        If you want to adjust the start of the bins based on a fixed timestamp:

        >>> start, end = '2000-10-01 23:30:00', '2000-10-02 00:30:00'
        >>> rng = pd.date_range(start, end, freq='7min')
        >>> ts = pd.Series(np.arange(len(rng)) * 3, index=rng)
        >>> ts
        2000-10-01 23:30:00     0
        2000-10-01 23:37:00     3
        2000-10-01 23:44:00     6
        2000-10-01 23:51:00     9
        2000-10-01 23:58:00    12
        2000-10-02 00:05:00    15
        2000-10-02 00:12:00    18
        2000-10-02 00:19:00    21
        2000-10-02 00:26:00    24
        Freq: 7min, dtype: int64

        >>> ts.resample('17min').sum()
        2000-10-01 23:14:00     0
        2000-10-01 23:31:00     9
        2000-10-01 23:48:00    21
        2000-10-02 00:05:00    54
        2000-10-02 00:22:00    24
        Freq: 17min, dtype: int64

        >>> ts.resample('17min', origin='epoch').sum()
        2000-10-01 23:18:00     0
        2000-10-01 23:35:00    18
        2000-10-01 23:52:00    27
        2000-10-02 00:09:00    39
        2000-10-02 00:26:00    24
        Freq: 17min, dtype: int64

        >>> ts.resample('17min', origin='2000-01-01').sum()
        2000-10-01 23:24:00     3
        2000-10-01 23:41:00    15
        2000-10-01 23:58:00    45
        2000-10-02 00:15:00    45
        Freq: 17min, dtype: int64

        If you want to adjust the start of the bins with an `offset` Timedelta, the two
        following lines are equivalent:

        >>> ts.resample('17min', origin='start').sum()
        2000-10-01 23:30:00     9
        2000-10-01 23:47:00    21
        2000-10-02 00:04:00    54
        2000-10-02 00:21:00    24
        Freq: 17min, dtype: int64

        >>> ts.resample('17min', offset='23h30min').sum()
        2000-10-01 23:30:00     9
        2000-10-01 23:47:00    21
        2000-10-02 00:04:00    54
        2000-10-02 00:21:00    24
        Freq: 17min, dtype: int64

        If you want to take the largest Timestamp as the end of the bins:

        >>> ts.resample('17min', origin='end').sum()
        2000-10-01 23:35:00     0
        2000-10-01 23:52:00    18
        2000-10-02 00:09:00    27
        2000-10-02 00:26:00    63
        Freq: 17min, dtype: int64

        In contrast with the `start_day`, you can use `end_day` to take the ceiling
        midnight of the largest Timestamp as the end of the bins and drop the bins
        not containing data:

        >>> ts.resample('17min', origin='end_day').sum()
        2000-10-01 23:38:00     3
        2000-10-01 23:55:00    15
        2000-10-02 00:12:00    45
        2000-10-02 00:29:00    45
        Freq: 17min, dtype: int64
        r)�
get_resamplerr�z^DataFrame.resample with axis=1 is deprecated. Do `frame.T.resample(...)` without axis instead.r��The 'axis' keyword in z@.resample is deprecated and will be removed in a future version.zThe 'kind' keyword in zv.resample is deprecated and will be removed in a future version. Explicitly cast the index to the desired type insteadNzThe 'convention' keyword in z�.resample is deprecated and will be removed in a future version. Explicitly cast PeriodIndex to DatetimeIndex before resampling instead.r�zSeries | DataFrame)rKr��closedr�r��
conventionr)r*�origin�offset�
group_keys)r~r�rr�rr�r�rcrUrr�r
)
r��ruler�r�r�r�r��onr*r�r�r�r�s
             r��resamplezNDFrame.resample�$sK��p
	7��s�~�~�%��(�(��.�D��q�y��
�
�D�!�/�1�	��
�
�,�T�$�Z�-@�-@�,A�BJ�J�!�/�1�	��D��s�~�~�%��M�M�(��d��)<�)<�(=�>H�H��+�-�
��D��S�^�^�+��M�M�.�t�D�z�/B�/B�.C�D���+�-�

�!�J���%�t�,������!�����!�

�
	
r�c�x�tjdtt���t	|j
t�std��t|j
�dk(r|jd��St|�}t	|t�s@|j|j
d�r"|j
d|jz
|zx}}n|j
d|zx}}t	|t�r:||j
vr,|j
j|d��}|jd	|S|j d	|S)
a�
        Select initial periods of time series data based on a date offset.

        .. deprecated:: 2.1
            :meth:`.first` is deprecated and will be removed in a future version.
            Please create a mask and filter using `.loc` instead.

        For a DataFrame with a sorted DatetimeIndex, this function can
        select the first few rows based on a date offset.

        Parameters
        ----------
        offset : str, DateOffset or dateutil.relativedelta
            The offset length of the data that will be selected. For instance,
            '1ME' will display all the rows having their index within the first month.

        Returns
        -------
        Series or DataFrame
            A subset of the caller.

        Raises
        ------
        TypeError
            If the index is not  a :class:`DatetimeIndex`

        See Also
        --------
        last : Select final periods of time series based on a date offset.
        at_time : Select values at a particular time of the day.
        between_time : Select values between particular times of the day.

        Examples
        --------
        >>> i = pd.date_range('2018-04-09', periods=4, freq='2D')
        >>> ts = pd.DataFrame({'A': [1, 2, 3, 4]}, index=i)
        >>> ts
                    A
        2018-04-09  1
        2018-04-11  2
        2018-04-13  3
        2018-04-15  4

        Get the rows for the first 3 days:

        >>> ts.first('3D')
                    A
        2018-04-09  1
        2018-04-11  2

        Notice the data for 3 first calendar days were returned, not the first
        3 days observed in the dataset, and therefore data for 2018-04-13 was
        not returned.
        zqfirst is deprecated and will be removed in a future version. Please create a mask and filter using `.loc` insteadr�z+'first' only supports a DatetimeIndex indexrFr��leftrMN)r�r�rcrUr�rr}r�r�r�rr�is_on_offset�baserRr|r)r�r��end_date�ends    r��firstz
NDFrame.first:&s��p	�
�
�
C��'�)�		
��$�*�*�m�4��I�J�J��t�z�z�?�a���9�9�%�9�(�(��6�"���&�$�'�F�,?�,?��
�
�1�
�,N�"�Z�Z��]�V�[�[�8�6�A�A�H�s�!�Z�Z��]�V�3�3�H�s��f�d�#��D�J�J�(>��*�*�)�)�(��)�@�C��9�9�T�c�?�"��x�x���~�r�c�z�tjdtt���t	|j
t�std��t|j
�dk(r|jd��St|�}|j
d|z
}|j
j|d�	�}|j|d
S)a3
        Select final periods of time series data based on a date offset.

        .. deprecated:: 2.1
            :meth:`.last` is deprecated and will be removed in a future version.
            Please create a mask and filter using `.loc` instead.

        For a DataFrame with a sorted DatetimeIndex, this function
        selects the last few rows based on a date offset.

        Parameters
        ----------
        offset : str, DateOffset, dateutil.relativedelta
            The offset length of the data that will be selected. For instance,
            '3D' will display all the rows having their index within the last 3 days.

        Returns
        -------
        Series or DataFrame
            A subset of the caller.

        Raises
        ------
        TypeError
            If the index is not  a :class:`DatetimeIndex`

        See Also
        --------
        first : Select initial periods of time series based on a date offset.
        at_time : Select values at a particular time of the day.
        between_time : Select values between particular times of the day.

        Notes
        -----
        .. deprecated:: 2.1.0
            Please create a mask and filter using `.loc` instead

        Examples
        --------
        >>> i = pd.date_range('2018-04-09', periods=4, freq='2D')
        >>> ts = pd.DataFrame({'A': [1, 2, 3, 4]}, index=i)
        >>> ts
                    A
        2018-04-09  1
        2018-04-11  2
        2018-04-13  3
        2018-04-15  4

        Get the rows for the last 3 days:

        >>> ts.last('3D')  # doctest: +SKIP
                    A
        2018-04-13  3
        2018-04-15  4

        Notice the data for 3 last calendar days were returned, not the last
        3 observed days in the dataset, and therefore data for 2018-04-11 was
        not returned.
        zplast is deprecated and will be removed in a future version. Please create a mask and filter using `.loc` insteadr�z*'last' only supports a DatetimeIndex indexrFr�r�rLrMN)
r�r�rcrUr�rr}r�r�r�rrRr|)r�r��
start_dater�s    r�razNDFrame.last�&s���z	�
�
�
C��'�)�		
��$�*�*�m�4��H�I�I��t�z�z�?�a���9�9�%�9�(�(��6�"���Z�Z��^�f�,�
��
�
�'�'�
��'�A���y�y��� � r�c�������
��j|��
�dvr
d}t|����
����fd�}|r@�jdk(r t�j�std���j
�}	n�}	||	�S)a�
        Compute numerical data ranks (1 through n) along axis.

        By default, equal values are assigned a rank that is the average of the
        ranks of those values.

        Parameters
        ----------
        axis : {0 or 'index', 1 or 'columns'}, default 0
            Index to direct ranking.
            For `Series` this parameter is unused and defaults to 0.
        method : {'average', 'min', 'max', 'first', 'dense'}, default 'average'
            How to rank the group of records that have the same value (i.e. ties):

            * average: average rank of the group
            * min: lowest rank in the group
            * max: highest rank in the group
            * first: ranks assigned in order they appear in the array
            * dense: like 'min', but rank always increases by 1 between groups.

        numeric_only : bool, default False
            For DataFrame objects, rank only numeric columns if set to True.

            .. versionchanged:: 2.0.0
                The default value of ``numeric_only`` is now ``False``.

        na_option : {'keep', 'top', 'bottom'}, default 'keep'
            How to rank NaN values:

            * keep: assign NaN rank to NaN values
            * top: assign lowest rank to NaN values
            * bottom: assign highest rank to NaN values

        ascending : bool, default True
            Whether or not the elements should be ranked in ascending order.
        pct : bool, default False
            Whether or not to display the returned rankings in percentile
            form.

        Returns
        -------
        same type as caller
            Return a Series or DataFrame with data ranks as values.

        See Also
        --------
        core.groupby.DataFrameGroupBy.rank : Rank of values within each group.
        core.groupby.SeriesGroupBy.rank : Rank of values within each group.

        Examples
        --------
        >>> df = pd.DataFrame(data={'Animal': ['cat', 'penguin', 'dog',
        ...                                    'spider', 'snake'],
        ...                         'Number_legs': [4, 2, 4, 8, np.nan]})
        >>> df
            Animal  Number_legs
        0      cat          4.0
        1  penguin          2.0
        2      dog          4.0
        3   spider          8.0
        4    snake          NaN

        Ties are assigned the mean of the ranks (by default) for the group.

        >>> s = pd.Series(range(5), index=list("abcde"))
        >>> s["d"] = s["b"]
        >>> s.rank()
        a    1.0
        b    2.5
        c    4.0
        d    2.5
        e    5.0
        dtype: float64

        The following example shows how the method behaves with the above
        parameters:

        * default_rank: this is the default behaviour obtained without using
          any parameter.
        * max_rank: setting ``method = 'max'`` the records that have the
          same values are ranked using the highest rank (e.g.: since 'cat'
          and 'dog' are both in the 2nd and 3rd position, rank 3 is assigned.)
        * NA_bottom: choosing ``na_option = 'bottom'``, if there are records
          with NaN values they are placed at the bottom of the ranking.
        * pct_rank: when setting ``pct = True``, the ranking is expressed as
          percentile rank.

        >>> df['default_rank'] = df['Number_legs'].rank()
        >>> df['max_rank'] = df['Number_legs'].rank(method='max')
        >>> df['NA_bottom'] = df['Number_legs'].rank(na_option='bottom')
        >>> df['pct_rank'] = df['Number_legs'].rank(pct=True)
        >>> df
            Animal  Number_legs  default_rank  max_rank  NA_bottom  pct_rank
        0      cat          4.0           2.5       3.0        2.5     0.625
        1  penguin          2.0           1.0       1.0        1.0     0.250
        2      dog          4.0           2.5       3.0        2.5     0.625
        3   spider          8.0           4.0       4.0        4.0     1.000
        4    snake          NaN           NaN       NaN        5.0       NaN
        >�top�keep�bottomz3na_option must be one of 'keep', 'top', or 'bottom'c�@��|jdk(r
|j}n|j}t|t�r|j�������}nt
j|�������}�	j|fi|j���}|j�	d��S)Nr)r�rbrX�	na_option�pct�rankra)rr�rfr�ry�_rank�algosr�r�rr�)
r�r��ranks�	ranks_objrXr�rbr�r�r�s
    ������r��rankerzNDFrame.rank.<locals>.rankerP's�����y�y�A�~����������&�.�1����!�!�'�'��%����
�
��!�!�'�'��
��*��)�)�%�O�4�3L�3L�3N�O�I��)�)�$�v�)�>�>r�r�zDSeries.rank does not allow numeric_only=True with non-numeric dtype.)rrrrer�r�r�)r�r�rb�numeric_onlyr�rXr�r�r�r�r�s` ` ```   @r�r�zNDFrame.rank�&s����Z�(�(��.���5�5�G�C��S�/�!�	?�	?�:��y�y�A�~�&6�t�z�z�&B��)����)�)�+�D��D��d�|�r��comparer�c	�X�t|�t|�ur?t|�jt|�j}}td|�d|�d|�d���||k(|j�|j�zz}|j	dd��|s"|j|�}|j|�}|s_t
|t�rE|j�}	|jd��}
|j|
|	f}|j|
|	f}n
||}||}t
|t�std	t|��d
���|dvrd}n|j|�}t||g||��}||jk\r|S|j|�}
tj |
j"�}tj$t'|��|
_t)t+d|
j,��d
gz}t
|t�r|j/||��}n|j/|�}|||j|��_tj$|j0|�j3d|j0|dzg�j4j7�}|j9||��}|S)Nzcan only compare 'z' (not 'z	') with 'r^Trar�r�zPassing 'result_names' as a z= is not supported. Provide 'result_names' as a tuple instead.)r�r)r�r�rr)rr�r�ror�rr�rkr�rrJrr�rr
rO�arrayr"r�r�r%rd�nlevels�reorder_levelsrK�reshaper=�flattenr�)r�r��
align_axis�
keep_shape�
keep_equal�result_names�cls_self�	cls_otherrL�cmask�rmaskr��diffr��ax_names�orderr�s                 r�r�zNDFrame.comparez's�����:�T�%�[�(�"&�t�*�"5�"5�t�E�{�7K�7K�i�H��$�X�J�h�y�k��8�*�TU�V��
��%�-�D�I�I�K�%�*�*�,�$>�?�@�����D�$��'���:�:�d�#�D��K�K��%�E���$��-����
�����a��(���x�x��u��-���	�	�%��,�/���D�z���d����,��.��.�t�L�/A�.B�CH�H��
�
��'��D��(�(��4�D��
�5�M���
���4�9�9���K�
�^�^�D�
!���8�8�B�H�H�%���9�9�S��]�+����U�1�b�j�j�)�*�a�S�0���d�L�)��&�&�u�4�&�8�D��&�&�u�-�D�+3�5�/����D��!�'�
�I�I�d�j�j��&�'�/�/��D�J�J�t�4D��4I�0J�K�M�M�U�U�W�	��y�y��t�y�,���r��outerc�N�|tjus$|tjus|	tjur;tjdt	|�j
�d�tt���|	tjurd}	|tjurd}|tjurd}|�t|�}|
tjur�dt	|�j
�d�}|
�G|jdk(r|jd	k(r|d
z
}n#|jd	k(r|jdk(r|dz
}tj|tt���nd}
|
dk(r�|j|jk7r�t|t�rY|j}||jD�
cic]}
|
|��c}
fi|j���}|j|||||||||	��	dd	St|t�rY|j}||jD�
cic]}
|
|��c}
fi|j���}|j|||||||||	��	dd	S|�|j!|�}t|t"�r|j|||||||||	��	\}}}nFt|t�r|j%|||||||||	��	\}}}nt'd
t	|�����t)t*|�}|jdk(s|dk(r�t|j,j.t0�ra|j,j2|j,j2k7r4|�2|j5d��}|j5d��}||_||_|j7|�}|j7|�}||fScc}
wcc}
w)a3
        Align two objects on their axes with the specified join method.

        Join method is specified for each axis Index.

        Parameters
        ----------
        other : DataFrame or Series
        join : {{'outer', 'inner', 'left', 'right'}}, default 'outer'
            Type of alignment to be performed.

            * left: use only keys from left frame, preserve key order.
            * right: use only keys from right frame, preserve key order.
            * outer: use union of keys from both frames, sort keys lexicographically.
            * inner: use intersection of keys from both frames,
              preserve the order of the left keys.

        axis : allowed axis of the other object, default None
            Align on index (0), columns (1), or both (None).
        level : int or level name, default None
            Broadcast across a level, matching Index values on the
            passed MultiIndex level.
        copy : bool, default True
            Always returns new objects. If copy=False and no reindexing is
            required then original objects are returned.

            .. note::
                The `copy` keyword will change behavior in pandas 3.0.
                `Copy-on-Write
                <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
                will be enabled by default, which means that all methods with a
                `copy` keyword will use a lazy copy mechanism to defer the copy and
                ignore the `copy` keyword. The `copy` keyword will be removed in a
                future version of pandas.

                You can already get the future behavior and improvements through
                enabling copy on write ``pd.options.mode.copy_on_write = True``
        fill_value : scalar, default np.nan
            Value to use for missing values. Defaults to NaN, but can be any
            "compatible" value.
        method : {{'backfill', 'bfill', 'pad', 'ffill', None}}, default None
            Method to use for filling holes in reindexed Series:

            - pad / ffill: propagate last valid observation forward to next valid.
            - backfill / bfill: use NEXT valid observation to fill gap.

            .. deprecated:: 2.1

        limit : int, default None
            If method is specified, this is the maximum number of consecutive
            NaN values to forward/backward fill. In other words, if there is
            a gap with more than this number of consecutive NaNs, it will only
            be partially filled. If method is not specified, this is the
            maximum number of entries along the entire axis where NaNs will be
            filled. Must be greater than 0 if not None.

            .. deprecated:: 2.1

        fill_axis : {axes_single_arg}, default 0
            Filling axis, method and limit.

            .. deprecated:: 2.1

        broadcast_axis : {axes_single_arg}, default None
            Broadcast values along this axis, if aligning two objects of
            different dimensions.

            .. deprecated:: 2.1

        Returns
        -------
        tuple of ({klass}, type of other)
            Aligned objects.

        Examples
        --------
        >>> df = pd.DataFrame(
        ...     [[1, 2, 3, 4], [6, 7, 8, 9]], columns=["D", "B", "E", "A"], index=[1, 2]
        ... )
        >>> other = pd.DataFrame(
        ...     [[10, 20, 30, 40], [60, 70, 80, 90], [600, 700, 800, 900]],
        ...     columns=["A", "B", "C", "D"],
        ...     index=[2, 3, 4],
        ... )
        >>> df
           D  B  E  A
        1  1  2  3  4
        2  6  7  8  9
        >>> other
            A    B    C    D
        2   10   20   30   40
        3   60   70   80   90
        4  600  700  800  900

        Align on columns:

        >>> left, right = df.align(other, join="outer", axis=1)
        >>> left
           A  B   C  D  E
        1  4  2 NaN  1  3
        2  9  7 NaN  6  8
        >>> right
            A    B    C    D   E
        2   10   20   30   40 NaN
        3   60   70   80   90 NaN
        4  600  700  800  900 NaN

        We can also align on the index:

        >>> left, right = df.align(other, join="outer", axis=0)
        >>> left
            D    B    E    A
        1  1.0  2.0  3.0  4.0
        2  6.0  7.0  8.0  9.0
        3  NaN  NaN  NaN  NaN
        4  NaN  NaN  NaN  NaN
        >>> right
            A      B      C      D
        1    NaN    NaN    NaN    NaN
        2   10.0   20.0   30.0   40.0
        3   60.0   70.0   80.0   90.0
        4  600.0  700.0  800.0  900.0

        Finally, the default `axis=None` will align on both index and columns:

        >>> left, right = df.align(other, join="outer", axis=None)
        >>> left
             A    B   C    D    E
        1  4.0  2.0 NaN  1.0  3.0
        2  9.0  7.0 NaN  6.0  8.0
        3  NaN  NaN NaN  NaN  NaN
        4  NaN  NaN NaN  NaN  NaN
        >>> right
               A      B      C      D   E
        1    NaN    NaN    NaN    NaN NaN
        2   10.0   20.0   30.0   40.0 NaN
        3   60.0   70.0   80.0   90.0 NaN
        4  600.0  700.0  800.0  900.0 NaN
        z3The 'method', 'limit', and 'fill_axis' keywords in zt.align are deprecated and will be removed in a future version. Call fillna directly on the returned objects instead.r�rNz The 'broadcast_axis' keyword in z=.align is deprecated and will be removed in a future version.r�rzz Use left = DataFrame({col: left for col in right.columns}, index=right.index) before calling `left.align(right)` instead.zy Use right = DataFrame({col: right for col in left.columns}, index=left.index) before calling `left.align(right)` instead)r.r�r*r�rorbr3�	fill_axiszunsupported type: Fr�)rr�r�r�rr�rcrUr�rr�rl�_constructor_expanddimrr�_align_framerrk�
_align_seriesr�r
r2rr�ri�tzr�r�)r�r�r.r�r*r�rorbr3r��broadcast_axisr��consr�r�r��_right�
join_indexrLs                   r��alignz
NDFrame.align�'s���|
�#�.�.�(��C�N�N�*�����.�
�M�M�E���:�&�&�'�(���+�-�

�����&��I��S�^�^�#��F��C�N�N�"��E���&�v�.�F�����/�3�4��:�3F�3F�2G�HF�F�
��)��9�9��>�e�j�j�A�o��Y��C��Y�Y�!�^��
�
�a���W��C�
�M�M�#�}�9I�9K�L�!�N��Q��4�9�9��
�
�#:��$�	�*��2�2���&+�m�m�4�m��Q��W�m�4��8=�8R�8R�8T���
��������)�!��'�'�
��1�
�
��E�9�-��3�3���'+�|�|�4�|�!�Q��X�|�4��8<�8Q�8Q�8S���
�(�(������)�!��'�)�
��1�
�
����(�(��.�D��e�\�*�'+�'8�'8������%���#�(9�
(�$�D�&�*���y�
)�'+�'9�'9������%���#�(:�
(�$�D�&�*��0��e��
�>�?�?��X�v�&���9�9��>�T�Q�Y��$�*�*�*�*�O�<��:�:�=�=�E�K�K�N�N�2�!�-� $�y�y�e�y�4�� %�
�
��
� 6��%/��
�&0���� � ��&���"�"�5�)���U�{���g5��(5s� 
N�	
N"c
��d\}
}d\}}
d\}}t|t�}|�|dk(rR|jj|j�s-|jj	|j||d��\}
}}
|�|dk(rT|sR|j
j|j
�s-|j
j	|j
||d��\}}}|rd|
|gi}n	|
|g||gd�}|j
|||d��}|j
|
|
g||gd�||d��}|�(|j||	|��}|j||	|��}|||
fS)	N�NNrT�r|r*�return_indexersr�)rr�)r�ror@�r�r3)r�rlrr�r.rrwr)r�r�r.r�r*r�rorbr3r�r��join_columns�ilidx�iridx�clidx�cridxrTr~r�rLs                    r�r�zNDFrame._align_frame�(s���$.� �
�L�!���u�!���u��t�Y�/�	��L�D�A�I�t�z�z�/@�/@����/M�'+�z�z�������U�D�(7�(�$�J��u�
�\�T�Q�Y���L�L�'�'��
�
�6�)-���):�):��
�
�4�u�d�*;�*�&�L�%����j�%�0�1�J�(�%�0�l�E�5J�K�J��*�*��T�j�T�+�
���,�,��U�#��u�(=�>��!��	-�
�����(�(��i�u�(�M�D��*�*�6�	��*�O�E��U�J�&�&r�c
��t|t�}
|rt�rd}|
s|�|dvrtd��|
r|dk(rtd��|s�|jj|j�rd\}}}
n-|jj
|j||d��\}}}
|
r|j|||�}nS|�|�|j|�	�}n<|jj||d|�
�}|j||j��}|j||
|�}n�|j}|jd}d\}}
|j|j�s#|j
|j||d��\}}}
|�%|jd�}|j|||�
�}|r||jur|j�}|j||j��}|
�|j|�	�}n|j||��}t|�xs|du}|r`t!||�\}}|�(|j#|||	��}|j#||��}n'|j%|||	��}|j%||��}|||fS)NF)Nrr�zMust specify axis=0 or 1r�z1cannot align series to a series other than axis 0�NNNTr�r�rRr�r�r�r�)r3r�)r3)r�rlrrrr�r.�_reindex_indexerr�r�rHr�r�r�r5rprYrr�)r�r�r.r�r*r�rorbr3r�rTr��lidx�ridxr�r�rL�fdatar��fill_nas                    r�r�zNDFrame._align_series')s����t�Y�/�	��'�)��D��d�l�t�<�/G��7�8�8������P�Q�Q���z�z� � ����-�)9�&�
�D�$�)-������K�K�T���*9�*�&�
�D�$���,�,�Z��t�D�����!3��y�y�d�y�+���)�)�3�3�J��1�SW�3�X���1�1�'����1�M���*�*�:�t�T�B�E��I�I�E����1��J�#�J�D�$��$�$�U�[�[�1�)3����K�K�T���*9�*�&�
�D�$����6�6�q�9���-�-�j�$�W�-�M�������*��
�
����-�-�e�%�*�*�-�E�D��|��
�
��
�-���
�
�j��
�>���
�#�;��d�(:���!7�
�F�!K��J���!��,�,�V�5�y�,�Q���.�.�v�U�.�C���{�{�:�U��{�K�����Z�u��=���U�J�&�&r�c�&
�t|d�}|�|j|�}tj||�}t	|t
�r�|jdk(r^|jdk(rO|jtt|j��D�cic]}||��c}d��}|j|_
|j|dd��d	}njt|d
�stj|�}|j|jk7rt!d��|j"|fi|j%��ddi��}t'|�}t)j*�5t)j,d
dt.��|j1|�}ddd�|j3d��}d}	|j4s�t	|t6�s0t9|�s�t!|	j;|j<����|j>D](}
t9|
�r�t!|	j;|
����|j@jBrL|j"|jEt&|��fi|j%���}n|jGt&�}|r|n|}|jI|jJ|jLd��}t	|t
�r�|j|jkr�|j|d||dd��d}|�|jO|�stP�|j|jkr�|jR}|d	k(rtjT|d�}n|dk(rtjT|d�}tjV||j�}n.tYd��t	|tZt
f�s
t]|d��}t	|tj^t`f�rX|j|jk7r|jdk7r0t!d��|j"|fi|j%��ddi��}|�d	}|jtc|dd	�k(rd}n|j|�dk(}|rM|j@je||||��}|jg||jh��}
|jk|
�S|j@jm|||��}|jg||jh��}
|
jo|�Scc}w#1swY���xYw) z�
        Equivalent to public method `where`, except that `other` is not
        applied as a function even if callable. Used in __setitem__.
        r�Nr�rFrrL)r.r�rrKz,Array conditional must be same shape as selfr�r}zDowncasting object dtype arrays)�categoryz5Boolean array expected for the condition, not {dtype}r�)r��na_valuerRr�)r.r�r*ror�)r�r�)r�r�z.cannot align with a higher dimensional NDFrameT)�
extract_numpyz4other must be the same shape as self when an ndarrayr)rL�newr�r�r�)r�rcr�)8rXrrs�apply_if_callabler�r�rr�rdr�rr�rsrO�
asanyarrayrKrr�rr�r��catch_warnings�filterwarningsrcr�r�rrkr`rrr�r<r�r�rGr�r5r?rr�rMrfr��broadcast_tor�rr{rryr �putmaskr�r�r�rr�)r�rcr�r�r�r*r�r'ror��_dtr�r�rvs              r��_wherezNDFrame._wherew)s���&�g�y�9�����(�(��.�D��'�'��d�3���d�G�$��y�y�A�~�$�)�)�q�.��2�2�&+�C����,=�&>�?�&>��Q��W�&>�?��3��� $�|�|����:�:�d��u�:�=�a�@�D��4��)��}�}�T�*���z�z�T�Z�Z�'� �!O�P�P�$�4�$�$�T�U�T�-F�-F�-H�U�u�U�D��'�]�
�
�
$�
$�
&��#�#��1�&�
�
�;�;�z�*�D�
'��!�!�u�!�-��E���z�z��d�L�1�$�T�*�$�S�Z�Z�d�j�j�Z�%A�B�B��;�;�C�(��-�(����#��)>�?�?�'��9�9�0�0�,�4�,�,��
�
�D�:�
�F���3�3�5��D��;�;�t�$�D���u�T���|�|�D�O�O�$�2H�2H�u�|�U���e�W�%��z�z�T�Y�Y�&��
�
�����#��
#������<��(;�(;�D�(A�+�+��:�:��	�	�)�!�M�M�E��q�y� "�
�
�5�'� :����� "�
�
�5�'� :���O�O�E�4�:�:�>�E�*�D����E�J��#8�9�!�%�t�<�E��e�b�j�j�.�9�:��{�{�d�j�j�(��9�9��>�
%�N���*��)�)���!�6�6�8��?D����<��D��9�9���v�q�1�1��E��)�)�$�/�1�4�E���y�y�(�(�d��U�QU�(�V�H��/�/��x�}�}�/�M�F��'�'��/�/��y�y������'��H�
�/�/��x�}�}�/�M�F��&�&�t�,�,��{@�'�
&�s�
T�.T�T)r�r�r*c��yr�rt�r�rcr�r�r�r*s      r�rz
NDFrame.where*rr�)r�r*c��yr�rtr�s      r�rz
NDFrame.where*rr�c��yr�rtr�s      r�rz
NDFrame.where'*rr��True�FalserrL)r�rc�cond_revr(�
name_otherc��t|d�}|r�tsGt�r=tj|�t
kr�t
jttd��n�ts{t�sq|j�ratj|�}t
}t|t�rt|d�r|dz
}||kr t
jttd��t!j"||�}|j%|||||�S)a�
        Replace values where the condition is {cond_rev}.

        Parameters
        ----------
        cond : bool {klass}, array-like, or callable
            Where `cond` is {cond}, keep the original value. Where
            {cond_rev}, replace with corresponding value from `other`.
            If `cond` is callable, it is computed on the {klass} and
            should return boolean {klass} or array. The callable must
            not change input {klass} (though pandas doesn't check it).
        other : scalar, {klass}, or callable
            Entries where `cond` is {cond_rev} are replaced with
            corresponding value from `other`.
            If other is callable, it is computed on the {klass} and
            should return scalar or {klass}. The callable must not
            change input {klass} (though pandas doesn't check it).
            If not specified, entries will be filled with the corresponding
            NULL value (``np.nan`` for numpy dtypes, ``pd.NA`` for extension
            dtypes).
        inplace : bool, default False
            Whether to perform the operation in place on the data.
        axis : int, default None
            Alignment axis if needed. For `Series` this parameter is
            unused and defaults to 0.
        level : int, default None
            Alignment level if needed.

        Returns
        -------
        Same type as caller or None if ``inplace=True``.

        See Also
        --------
        :func:`DataFrame.{name_other}` : Return an object of same shape as
            self.

        Notes
        -----
        The {name} method is an application of the if-then idiom. For each
        element in the calling DataFrame, if ``cond`` is ``{cond}`` the
        element is used; otherwise the corresponding element from the DataFrame
        ``other`` is used. If the axis of ``other`` does not align with axis of
        ``cond`` {klass}, the misaligned index positions will be filled with
        {cond_rev}.

        The signature for :func:`DataFrame.where` differs from
        :func:`numpy.where`. Roughly ``df1.where(m, df2)`` is equivalent to
        ``np.where(m, df1, df2)``.

        For further details and examples see the ``{name}`` documentation in
        :ref:`indexing <indexing.where_mask>`.

        The dtype of the object takes precedence. The fill value is casted to
        the object's dtype, if this can be done losslessly.

        Examples
        --------
        >>> s = pd.Series(range(5))
        >>> s.where(s > 0)
        0    NaN
        1    1.0
        2    2.0
        3    3.0
        4    4.0
        dtype: float64
        >>> s.mask(s > 0)
        0    0.0
        1    NaN
        2    NaN
        3    NaN
        4    NaN
        dtype: float64

        >>> s = pd.Series(range(5))
        >>> t = pd.Series([True, False])
        >>> s.where(t, 99)
        0     0
        1    99
        2    99
        3    99
        4    99
        dtype: int64
        >>> s.mask(t, 99)
        0    99
        1     1
        2    99
        3    99
        4    99
        dtype: int64

        >>> s.where(s > 1, 10)
        0    10
        1    10
        2    2
        3    3
        4    4
        dtype: int64
        >>> s.mask(s > 1, 10)
        0     0
        1     1
        2    10
        3    10
        4    10
        dtype: int64

        >>> df = pd.DataFrame(np.arange(10).reshape(-1, 2), columns=['A', 'B'])
        >>> df
           A  B
        0  0  1
        1  2  3
        2  4  5
        3  6  7
        4  8  9
        >>> m = df % 3 == 0
        >>> df.where(m, -df)
           A  B
        0  0 -1
        1 -2  3
        2 -4 -5
        3  6 -7
        4 -8  9
        >>> df.where(m, -df) == np.where(m, df, -df)
              A     B
        0  True  True
        1  True  True
        2  True  True
        3  True  True
        4  True  True
        >>> df.where(m, -df) == df.mask(~m, -df)
              A     B
        0  True  True
        1  True  True
        2  True  True
        3  True  True
        4  True  True
        r�rr�r�r�)rXrGrr	r
rHr�r�rPrLrCr�rlrsrQrcrsr�r��r�rcr�r�r�r*r
rs        r�rz
NDFrame.where3*s���t&�g�y�9����/�1��?�?�4�(�I�5��M�M�6�.�#$���+�-��1�1�3��o�o�d�+��%�	��d�I�.�7�4��3K���N�I��)�#��M�M�>�%�#$���(�(���5���{�{�4����u�=�=r�c��yr�rtr�s      r�rLzNDFrame.mask�*rr�c��yr�rtr�s      r�rLzNDFrame.mask�*rr�c��yr�rtr�s      r�rLzNDFrame.mask+rr�c��t|d�}|r�tsGt�r=tj|�t
kr�t
jttd��n�ts{t�sq|j�ratj|�}t
}t|t�rt|d�r|dz
}||kr t
jttd��t!j"||�}t!j"||�}t|d�st%j&|�}|j)|||||��S)Nr�rr�r�r�r�)r�r�r�r*)rXrGrr	r
rHr�r�rPrLrCr�rlrsrQrcrsr�rOr�r�r�s        r�rLzNDFrame.mask+s��$&�g�y�9����/�1��?�?�4�(�I�5��M�M�6�.�#$���+�-��1�1�3��o�o�d�+��%�	��d�I�.�7�4��3K���N�I��)�#��M�M�>�%�#$���'�'��d�3���(�(���5���t�\�*��8�8�D�>�D��{�{�
�E������
�	
r�c�n�|j|�}|�F|tjur4tjdt
t
���tj}|dk(r|jd��St|�r3t|t�r#|j�j||||��Stt|�}|�c|j|�}|dk(sJ�|jj||��}|j!||j"��j%|d	�
�S|j'|||�S)a�
        Shift index by desired number of periods with an optional time `freq`.

        When `freq` is not passed, shift the index without realigning the data.
        If `freq` is passed (in this case, the index must be date or datetime,
        or it will raise a `NotImplementedError`), the index will be
        increased using the periods and the `freq`. `freq` can be inferred
        when specified as "infer" as long as either freq or inferred_freq
        attribute is set in the index.

        Parameters
        ----------
        periods : int or Sequence
            Number of periods to shift. Can be positive or negative.
            If an iterable of ints, the data will be shifted once by each int.
            This is equivalent to shifting by one value at a time and
            concatenating all resulting frames. The resulting columns will have
            the shift suffixed to their column names. For multiple periods,
            axis must not be 1.
        freq : DateOffset, tseries.offsets, timedelta, or str, optional
            Offset to use from the tseries module or time rule (e.g. 'EOM').
            If `freq` is specified then the index values are shifted but the
            data is not realigned. That is, use `freq` if you would like to
            extend the index when shifting and preserve the original data.
            If `freq` is specified as "infer" then it will be inferred from
            the freq or inferred_freq attributes of the index. If neither of
            those attributes exist, a ValueError is thrown.
        axis : {{0 or 'index', 1 or 'columns', None}}, default None
            Shift direction. For `Series` this parameter is unused and defaults to 0.
        fill_value : object, optional
            The scalar value to use for newly introduced missing values.
            the default depends on the dtype of `self`.
            For numeric data, ``np.nan`` is used.
            For datetime, timedelta, or period data, etc. :attr:`NaT` is used.
            For extension dtypes, ``self.dtype.na_value`` is used.
        suffix : str, optional
            If str and periods is an iterable, this is added after the column
            name and before the shift value for each shifted column name.

        Returns
        -------
        {klass}
            Copy of input object, shifted.

        See Also
        --------
        Index.shift : Shift values of Index.
        DatetimeIndex.shift : Shift values of DatetimeIndex.
        PeriodIndex.shift : Shift values of PeriodIndex.

        Examples
        --------
        >>> df = pd.DataFrame({{"Col1": [10, 20, 15, 30, 45],
        ...                    "Col2": [13, 23, 18, 33, 48],
        ...                    "Col3": [17, 27, 22, 37, 52]}},
        ...                   index=pd.date_range("2020-01-01", "2020-01-05"))
        >>> df
                    Col1  Col2  Col3
        2020-01-01    10    13    17
        2020-01-02    20    23    27
        2020-01-03    15    18    22
        2020-01-04    30    33    37
        2020-01-05    45    48    52

        >>> df.shift(periods=3)
                    Col1  Col2  Col3
        2020-01-01   NaN   NaN   NaN
        2020-01-02   NaN   NaN   NaN
        2020-01-03   NaN   NaN   NaN
        2020-01-04  10.0  13.0  17.0
        2020-01-05  20.0  23.0  27.0

        >>> df.shift(periods=1, axis="columns")
                    Col1  Col2  Col3
        2020-01-01   NaN    10    13
        2020-01-02   NaN    20    23
        2020-01-03   NaN    15    18
        2020-01-04   NaN    30    33
        2020-01-05   NaN    45    48

        >>> df.shift(periods=3, fill_value=0)
                    Col1  Col2  Col3
        2020-01-01     0     0     0
        2020-01-02     0     0     0
        2020-01-03     0     0     0
        2020-01-04    10    13    17
        2020-01-05    20    23    27

        >>> df.shift(periods=3, freq="D")
                    Col1  Col2  Col3
        2020-01-04    10    13    17
        2020-01-05    20    23    27
        2020-01-06    15    18    22
        2020-01-07    30    33    37
        2020-01-08    45    48    52

        >>> df.shift(periods=3, freq="infer")
                    Col1  Col2  Col3
        2020-01-04    10    13    17
        2020-01-05    20    23    27
        2020-01-06    15    18    22
        2020-01-07    30    33    37
        2020-01-08    45    48    52

        >>> df['Col1'].shift(periods=[0, 1, 2])
                    Col1_0  Col1_1  Col1_2
        2020-01-01      10     NaN     NaN
        2020-01-02      20    10.0     NaN
        2020-01-03      15    20.0    10.0
        2020-01-04      30    15.0    20.0
        2020-01-05      45    30.0    15.0
        Nz�Passing a 'freq' together with a 'fill_value' silently ignores the fill_value and is deprecated. This will raise in a future version.r�rr�)�periodsrKr�ro)r�ror��shiftra)rrr�r�r�rcrUr�rcr�rlrVr�r
rr�r�r�r��_shift_with_freq)r�r�rKr�rorVr�s       r�r�z
NDFrame.shiftI+s(��r�$�$�T�*����
�#�.�.� @��M�M���+�-�
����J��a�<��9�9�$�9�'�'��� �Z��i�%@��=�=�?�(�(��d��*�)��
��s�G�$���<��(�(��.�D��1�9��9��y�y���w�:��N�H��-�-��x�}�}�.���l�4��l�0�
1��$�$�W�d�D�9�9r�c	�h�|j|�}|dk(r+t|dd�}|�
t|dd�}|�:d}t|��t|t�rt|t
�}t
||��}t|t
�r}t
|j�}||k7rQ|�J�tdt|j|j��dt|j|j�����|j|�}n|j||�}|j||��}	|	j|d	�
�S)Nr\rK�
inferred_freqz6Freq was not set in the index hence cannot be inferred)�	is_periodzGiven freq z! does not match PeriodIndex freq r�r�ra)r
r rr�r�r�rrKrr�r(r�rVr�)
r�r�r�rKrr�r�	orig_freqr
rvs
          r�r�zNDFrame._shift_with_freq�+s*�����t�$���7�?��5�&�$�/�D��|��u�o�t�<���|�N�� ��o�%�
��c�
"�"�5�+�6�I��T�Y�7�D��e�[�)�!�%�*�*�-�I��y� � �,�,�,� �!�"8�������"K�!L�M7�-�i�k�k�9�>�>�J�K�M���
�[�[��)�F��[�[��$�/�F����v�D��1���"�"�4��"�8�8r�c��|�d}|j|�}|j|�}|js|jst	d��|j
rddlm}||�}||�}|�|�||kDrt	d|�d|����t|�dkDr#|jr|j�dkDr||}}tdd�g|jz}t||�||<|jt|�}t|t�r,t!||j#|�|j%||��|j'|xrt)���}|S)	a�
        Truncate a Series or DataFrame before and after some index value.

        This is a useful shorthand for boolean indexing based on index
        values above or below certain thresholds.

        Parameters
        ----------
        before : date, str, int
            Truncate all rows before this index value.
        after : date, str, int
            Truncate all rows after this index value.
        axis : {0 or 'index', 1 or 'columns'}, optional
            Axis to truncate. Truncates the index (rows) by default.
            For `Series` this parameter is unused and defaults to 0.
        copy : bool, default is True,
            Return a copy of the truncated section.

            .. note::
                The `copy` keyword will change behavior in pandas 3.0.
                `Copy-on-Write
                <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
                will be enabled by default, which means that all methods with a
                `copy` keyword will use a lazy copy mechanism to defer the copy and
                ignore the `copy` keyword. The `copy` keyword will be removed in a
                future version of pandas.

                You can already get the future behavior and improvements through
                enabling copy on write ``pd.options.mode.copy_on_write = True``

        Returns
        -------
        type of caller
            The truncated Series or DataFrame.

        See Also
        --------
        DataFrame.loc : Select a subset of a DataFrame by label.
        DataFrame.iloc : Select a subset of a DataFrame by position.

        Notes
        -----
        If the index being truncated contains only datetime values,
        `before` and `after` may be specified as strings instead of
        Timestamps.

        Examples
        --------
        >>> df = pd.DataFrame({'A': ['a', 'b', 'c', 'd', 'e'],
        ...                    'B': ['f', 'g', 'h', 'i', 'j'],
        ...                    'C': ['k', 'l', 'm', 'n', 'o']},
        ...                   index=[1, 2, 3, 4, 5])
        >>> df
           A  B  C
        1  a  f  k
        2  b  g  l
        3  c  h  m
        4  d  i  n
        5  e  j  o

        >>> df.truncate(before=2, after=4)
           A  B  C
        2  b  g  l
        3  c  h  m
        4  d  i  n

        The columns of a DataFrame can be truncated.

        >>> df.truncate(before="A", after="B", axis="columns")
           A  B
        1  a  f
        2  b  g
        3  c  h
        4  d  i
        5  e  j

        For Series, only rows can be truncated.

        >>> df['A'].truncate(before=2, after=4)
        2    b
        3    c
        4    d
        Name: A, dtype: object

        The index values in ``truncate`` can be datetimes or string
        dates.

        >>> dates = pd.date_range('2016-01-01', '2016-02-01', freq='s')
        >>> df = pd.DataFrame(index=dates, data={'A': 1})
        >>> df.tail()
                             A
        2016-01-31 23:59:56  1
        2016-01-31 23:59:57  1
        2016-01-31 23:59:58  1
        2016-01-31 23:59:59  1
        2016-02-01 00:00:00  1

        >>> df.truncate(before=pd.Timestamp('2016-01-05'),
        ...             after=pd.Timestamp('2016-01-10')).tail()
                             A
        2016-01-09 23:59:56  1
        2016-01-09 23:59:57  1
        2016-01-09 23:59:58  1
        2016-01-09 23:59:59  1
        2016-01-10 00:00:00  1

        Because the index is a DatetimeIndex containing only dates, we can
        specify `before` and `after` as strings. They will be coerced to
        Timestamps before truncation.

        >>> df.truncate('2016-01-05', '2016-01-10').tail()
                             A
        2016-01-09 23:59:56  1
        2016-01-09 23:59:57  1
        2016-01-09 23:59:58  1
        2016-01-09 23:59:59  1
        2016-01-10 00:00:00  1

        Note that ``truncate`` assumes a 0 value for any unspecified time
        component (midnight). This differs from partial string slicing, which
        returns any partially matching dates.

        >>> df.loc['2016-01-05':'2016-01-10', :].tail()
                             A
        2016-01-10 23:59:55  1
        2016-01-10 23:59:56  1
        2016-01-10 23:59:57  1
        2016-01-10 23:59:58  1
        2016-01-10 23:59:59  1
        Nrz truncate requires a sorted index)�to_datetimez
Truncate: z must be after r�r�)rr
rO�is_monotonic_decreasingr�
_is_all_dates�pandas.core.tools.datetimesrr�r�rzrrrJr�rrYr�truncater�r)	r��before�afterr�r�r�r�slicerrvs	         r�rzNDFrame.truncate,sG��T�<��D��$�$�T�*��
�^�^�D�
!���)�)�"�2L�2L��?�@�@����?� ��(�F���&�E���%�"3�����z�%����x�H�I�I��r�7�Q�;�2�5�5�"�*�*�,��:J�!�6�E�F���d�#�$�t�~�~�5���V�U�+��t�����%��-�(���b�*�%��F�D�/�/��5�r�{�{�6�5�7Q�R����$�"D�/B�/D�+D��E���
r�c������j����j��}��fd�}t|t�r;|j	|�}||j
||�}|j
||��}n)|dd|jfvrtd|�d���|||�}�j|xrt���}|j|�d�	�}|j�d
��S)a�
        Convert tz-aware axis to target time zone.

        Parameters
        ----------
        tz : str or tzinfo object or None
            Target time zone. Passing ``None`` will convert to
            UTC and remove the timezone information.
        axis : {{0 or 'index', 1 or 'columns'}}, default 0
            The axis to convert
        level : int, str, default None
            If axis is a MultiIndex, convert a specific level. Otherwise
            must be None.
        copy : bool, default True
            Also make a copy of the underlying data.

            .. note::
                The `copy` keyword will change behavior in pandas 3.0.
                `Copy-on-Write
                <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
                will be enabled by default, which means that all methods with a
                `copy` keyword will use a lazy copy mechanism to defer the copy and
                ignore the `copy` keyword. The `copy` keyword will be removed in a
                future version of pandas.

                You can already get the future behavior and improvements through
                enabling copy on write ``pd.options.mode.copy_on_write = True``

        Returns
        -------
        {klass}
            Object with time zone converted axis.

        Raises
        ------
        TypeError
            If the axis is tz-naive.

        Examples
        --------
        Change to another time zone:

        >>> s = pd.Series(
        ...     [1],
        ...     index=pd.DatetimeIndex(['2018-09-15 01:30:00+02:00']),
        ... )
        >>> s.tz_convert('Asia/Shanghai')
        2018-09-15 07:30:00+08:00    1
        dtype: int64

        Pass None to convert to UTC and get a tz-naive index:

        >>> s = pd.Series([1],
        ...               index=pd.DatetimeIndex(['2018-09-15 01:30:00+02:00']))
        >>> s.tz_convert(None)
        2018-09-14 23:30:00    1
        dtype: int64
        c���t|d�s<t|�dkDr�j��}t|�d���t	g|��}|S|j|�}|S)N�
tz_convertr�, is not a valid DatetimeIndex or PeriodIndex�r�)rsr�rr�r}r)r�r��ax_namer�r�s   ��r��_tz_convertz'NDFrame.tz_convert.<locals>._tz_convert�,sj����2�|�,��r�7�Q�;�"�1�1�$�7�G�#�"�)�#O�P���#�2�"�-���I��]�]�2�&���Ir�r�Nr�
The level �
 is not validr�FrRrra)
rr
r�rr��levels�
set_levelsr(rr�rrVr�)	r�r�r�r*r�r�r�	new_levelrvs	` `      r�rzNDFrame.tz_convert�,s����~�$�$�T�*��
�^�^�D�
!��
	��b�*�%��(�(��/�E�#�B�I�I�e�$4�b�9�I����y���6�B��T�1�b�g�g�.�.� �:�e�W�M�!B�C�C��R��$�B����� B�-@�-B�)B��C������$�U��;���"�"�4��"�=�=r�c�(���d}||vr%t|tj�std���j	����j��}��fd�}	t|t�r=|j|�}|	|j||||�}
|j|
|��}n+|dd|jfvrtd|�d���|	||||�}�j|xrt��	�}|j|�d
��}|j�d�
�S)a
        Localize tz-naive index of a Series or DataFrame to target time zone.

        This operation localizes the Index. To localize the values in a
        timezone-naive Series, use :meth:`Series.dt.tz_localize`.

        Parameters
        ----------
        tz : str or tzinfo or None
            Time zone to localize. Passing ``None`` will remove the
            time zone information and preserve local time.
        axis : {{0 or 'index', 1 or 'columns'}}, default 0
            The axis to localize
        level : int, str, default None
            If axis ia a MultiIndex, localize a specific level. Otherwise
            must be None.
        copy : bool, default True
            Also make a copy of the underlying data.

            .. note::
                The `copy` keyword will change behavior in pandas 3.0.
                `Copy-on-Write
                <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
                will be enabled by default, which means that all methods with a
                `copy` keyword will use a lazy copy mechanism to defer the copy and
                ignore the `copy` keyword. The `copy` keyword will be removed in a
                future version of pandas.

                You can already get the future behavior and improvements through
                enabling copy on write ``pd.options.mode.copy_on_write = True``
        ambiguous : 'infer', bool-ndarray, 'NaT', default 'raise'
            When clocks moved backward due to DST, ambiguous times may arise.
            For example in Central European Time (UTC+01), when going from
            03:00 DST to 02:00 non-DST, 02:30:00 local time occurs both at
            00:30:00 UTC and at 01:30:00 UTC. In such a situation, the
            `ambiguous` parameter dictates how ambiguous times should be
            handled.

            - 'infer' will attempt to infer fall dst-transition hours based on
              order
            - bool-ndarray where True signifies a DST time, False designates
              a non-DST time (note that this flag is only applicable for
              ambiguous times)
            - 'NaT' will return NaT where there are ambiguous times
            - 'raise' will raise an AmbiguousTimeError if there are ambiguous
              times.
        nonexistent : str, default 'raise'
            A nonexistent time does not exist in a particular timezone
            where clocks moved forward due to DST. Valid values are:

            - 'shift_forward' will shift the nonexistent time forward to the
              closest existing time
            - 'shift_backward' will shift the nonexistent time backward to the
              closest existing time
            - 'NaT' will return NaT where there are nonexistent times
            - timedelta objects will shift nonexistent times by the timedelta
            - 'raise' will raise an NonExistentTimeError if there are
              nonexistent times.

        Returns
        -------
        {klass}
            Same type as the input.

        Raises
        ------
        TypeError
            If the TimeSeries is tz-aware and tz is not None.

        Examples
        --------
        Localize local times:

        >>> s = pd.Series(
        ...     [1],
        ...     index=pd.DatetimeIndex(['2018-09-15 01:30:00']),
        ... )
        >>> s.tz_localize('CET')
        2018-09-15 01:30:00+02:00    1
        dtype: int64

        Pass None to convert to tz-naive index and preserve local time:

        >>> s = pd.Series([1],
        ...               index=pd.DatetimeIndex(['2018-09-15 01:30:00+02:00']))
        >>> s.tz_localize(None)
        2018-09-15 01:30:00    1
        dtype: int64

        Be careful with DST changes. When there is sequential data, pandas
        can infer the DST time:

        >>> s = pd.Series(range(7),
        ...               index=pd.DatetimeIndex(['2018-10-28 01:30:00',
        ...                                       '2018-10-28 02:00:00',
        ...                                       '2018-10-28 02:30:00',
        ...                                       '2018-10-28 02:00:00',
        ...                                       '2018-10-28 02:30:00',
        ...                                       '2018-10-28 03:00:00',
        ...                                       '2018-10-28 03:30:00']))
        >>> s.tz_localize('CET', ambiguous='infer')
        2018-10-28 01:30:00+02:00    0
        2018-10-28 02:00:00+02:00    1
        2018-10-28 02:30:00+02:00    2
        2018-10-28 02:00:00+01:00    3
        2018-10-28 02:30:00+01:00    4
        2018-10-28 03:00:00+01:00    5
        2018-10-28 03:30:00+01:00    6
        dtype: int64

        In some cases, inferring the DST is impossible. In such cases, you can
        pass an ndarray to the ambiguous parameter to set the DST explicitly

        >>> s = pd.Series(range(3),
        ...               index=pd.DatetimeIndex(['2018-10-28 01:20:00',
        ...                                       '2018-10-28 02:36:00',
        ...                                       '2018-10-28 03:46:00']))
        >>> s.tz_localize('CET', ambiguous=np.array([True, True, False]))
        2018-10-28 01:20:00+02:00    0
        2018-10-28 02:36:00+02:00    1
        2018-10-28 03:46:00+01:00    2
        dtype: int64

        If the DST transition causes nonexistent times, you can shift these
        dates forward or backward with a timedelta object or `'shift_forward'`
        or `'shift_backward'`.

        >>> s = pd.Series(range(2),
        ...               index=pd.DatetimeIndex(['2015-03-29 02:30:00',
        ...                                       '2015-03-29 03:30:00']))
        >>> s.tz_localize('Europe/Warsaw', nonexistent='shift_forward')
        2015-03-29 03:00:00+02:00    0
        2015-03-29 03:30:00+02:00    1
        dtype: int64
        >>> s.tz_localize('Europe/Warsaw', nonexistent='shift_backward')
        2015-03-29 01:59:59.999999999+01:00    0
        2015-03-29 03:30:00+02:00              1
        dtype: int64
        >>> s.tz_localize('Europe/Warsaw', nonexistent=pd.Timedelta('1h'))
        2015-03-29 03:30:00+02:00    0
        2015-03-29 03:30:00+02:00    1
        dtype: int64
        )r��NaT�
shift_forward�shift_backwardzoThe nonexistent argument must be one of 'raise', 'NaT', 'shift_forward', 'shift_backward' or a timedelta objectc���t|d�s<t|�dkDr�j��}t|�d���t	g|��}|S|j|||��}|S)N�tz_localizerrr)�	ambiguous�nonexistent)rsr�rr�r}r)r�r�rrrr�r�s     ��r��_tz_localizez)NDFrame.tz_localize.<locals>._tz_localize�-sp����2�}�-��r�7�Q�;�"�1�1�$�7�G�#�"�)�#O�P���#�2�"�-���I��^�^�B�)��^�U���Ir�r�Nrrrr�FrRrra)r��dt�	timedeltarrr
rr�rrr(r�rrVr�)r�r�r�r*r�rr�nonexistent_optionsr�r rrvs` `         r�rzNDFrame.tz_localize-s#���tR���1�1�*�����;
��%��
��$�$�T�*��
�^�^�D�
!��
	��b�*�%��(�(��/�E�$�R�Y�Y�u�%5�r�9�k�R�I����y���6�B��T�1�b�g�g�.�.� �:�e�W�M�!B�C�C��b�"�i��=�B����� B�-@�-B�)B��C������$�U��;���"�"�4�
�"�>�>r�c�B�t||||��j|d��S)a�!
        Generate descriptive statistics.

        Descriptive statistics include those that summarize the central
        tendency, dispersion and shape of a
        dataset's distribution, excluding ``NaN`` values.

        Analyzes both numeric and object series, as well
        as ``DataFrame`` column sets of mixed data types. The output
        will vary depending on what is provided. Refer to the notes
        below for more detail.

        Parameters
        ----------
        percentiles : list-like of numbers, optional
            The percentiles to include in the output. All should
            fall between 0 and 1. The default is
            ``[.25, .5, .75]``, which returns the 25th, 50th, and
            75th percentiles.
        include : 'all', list-like of dtypes or None (default), optional
            A white list of data types to include in the result. Ignored
            for ``Series``. Here are the options:

            - 'all' : All columns of the input will be included in the output.
            - A list-like of dtypes : Limits the results to the
              provided data types.
              To limit the result to numeric types submit
              ``numpy.number``. To limit it instead to object columns submit
              the ``numpy.object`` data type. Strings
              can also be used in the style of
              ``select_dtypes`` (e.g. ``df.describe(include=['O'])``). To
              select pandas categorical columns, use ``'category'``
            - None (default) : The result will include all numeric columns.
        exclude : list-like of dtypes or None (default), optional,
            A black list of data types to omit from the result. Ignored
            for ``Series``. Here are the options:

            - A list-like of dtypes : Excludes the provided data types
              from the result. To exclude numeric types submit
              ``numpy.number``. To exclude object columns submit the data
              type ``numpy.object``. Strings can also be used in the style of
              ``select_dtypes`` (e.g. ``df.describe(exclude=['O'])``). To
              exclude pandas categorical columns, use ``'category'``
            - None (default) : The result will exclude nothing.

        Returns
        -------
        Series or DataFrame
            Summary statistics of the Series or Dataframe provided.

        See Also
        --------
        DataFrame.count: Count number of non-NA/null observations.
        DataFrame.max: Maximum of the values in the object.
        DataFrame.min: Minimum of the values in the object.
        DataFrame.mean: Mean of the values.
        DataFrame.std: Standard deviation of the observations.
        DataFrame.select_dtypes: Subset of a DataFrame including/excluding
            columns based on their dtype.

        Notes
        -----
        For numeric data, the result's index will include ``count``,
        ``mean``, ``std``, ``min``, ``max`` as well as lower, ``50`` and
        upper percentiles. By default the lower percentile is ``25`` and the
        upper percentile is ``75``. The ``50`` percentile is the
        same as the median.

        For object data (e.g. strings or timestamps), the result's index
        will include ``count``, ``unique``, ``top``, and ``freq``. The ``top``
        is the most common value. The ``freq`` is the most common value's
        frequency. Timestamps also include the ``first`` and ``last`` items.

        If multiple object values have the highest count, then the
        ``count`` and ``top`` results will be arbitrarily chosen from
        among those with the highest count.

        For mixed data types provided via a ``DataFrame``, the default is to
        return only an analysis of numeric columns. If the dataframe consists
        only of object and categorical data without any numeric columns, the
        default is to return an analysis of both the object and categorical
        columns. If ``include='all'`` is provided as an option, the result
        will include a union of attributes of each type.

        The `include` and `exclude` parameters can be used to limit
        which columns in a ``DataFrame`` are analyzed for the output.
        The parameters are ignored when analyzing a ``Series``.

        Examples
        --------
        Describing a numeric ``Series``.

        >>> s = pd.Series([1, 2, 3])
        >>> s.describe()
        count    3.0
        mean     2.0
        std      1.0
        min      1.0
        25%      1.5
        50%      2.0
        75%      2.5
        max      3.0
        dtype: float64

        Describing a categorical ``Series``.

        >>> s = pd.Series(['a', 'a', 'b', 'c'])
        >>> s.describe()
        count     4
        unique    3
        top       a
        freq      2
        dtype: object

        Describing a timestamp ``Series``.

        >>> s = pd.Series([
        ...     np.datetime64("2000-01-01"),
        ...     np.datetime64("2010-01-01"),
        ...     np.datetime64("2010-01-01")
        ... ])
        >>> s.describe()
        count                      3
        mean     2006-09-01 08:00:00
        min      2000-01-01 00:00:00
        25%      2004-12-31 12:00:00
        50%      2010-01-01 00:00:00
        75%      2010-01-01 00:00:00
        max      2010-01-01 00:00:00
        dtype: object

        Describing a ``DataFrame``. By default only numeric fields
        are returned.

        >>> df = pd.DataFrame({'categorical': pd.Categorical(['d', 'e', 'f']),
        ...                    'numeric': [1, 2, 3],
        ...                    'object': ['a', 'b', 'c']
        ...                    })
        >>> df.describe()
               numeric
        count      3.0
        mean       2.0
        std        1.0
        min        1.0
        25%        1.5
        50%        2.0
        75%        2.5
        max        3.0

        Describing all columns of a ``DataFrame`` regardless of data type.

        >>> df.describe(include='all')  # doctest: +SKIP
               categorical  numeric object
        count            3      3.0      3
        unique           3      NaN      3
        top              f      NaN      a
        freq             1      NaN      1
        mean           NaN      2.0    NaN
        std            NaN      1.0    NaN
        min            NaN      1.0    NaN
        25%            NaN      1.5    NaN
        50%            NaN      2.0    NaN
        75%            NaN      2.5    NaN
        max            NaN      3.0    NaN

        Describing a column from a ``DataFrame`` by accessing it as
        an attribute.

        >>> df.numeric.describe()
        count    3.0
        mean     2.0
        std      1.0
        min      1.0
        25%      1.5
        50%      2.0
        75%      2.5
        max      3.0
        Name: numeric, dtype: float64

        Including only numeric columns in a ``DataFrame`` description.

        >>> df.describe(include=[np.number])
               numeric
        count      3.0
        mean       2.0
        std        1.0
        min        1.0
        25%        1.5
        50%        2.0
        75%        2.5
        max        3.0

        Including only string columns in a ``DataFrame`` description.

        >>> df.describe(include=[object])  # doctest: +SKIP
               object
        count       3
        unique      3
        top         a
        freq        1

        Including only categorical columns from a ``DataFrame`` description.

        >>> df.describe(include=['category'])
               categorical
        count            3
        unique           3
        top              d
        freq             1

        Excluding numeric columns from a ``DataFrame`` description.

        >>> df.describe(exclude=[np.number])  # doctest: +SKIP
               categorical object
        count            3      3
        unique           3      3
        top              f      a
        freq             1      1

        Excluding object columns from a ``DataFrame`` description.

        >>> df.describe(exclude=[object])  # doctest: +SKIP
               categorical  numeric
        count            3      3.0
        unique           3      NaN
        top              f      NaN
        freq             1      NaN
        mean           NaN      2.0
        std            NaN      1.0
        min            NaN      1.0
        25%            NaN      1.5
        50%            NaN      2.0
        75%            NaN      2.5
        max            NaN      3.0
        )r�r��exclude�percentiles�describera)r�r�)r�r&r�r%s    r�r'zNDFrame.describe�-s.��d ����#�	
�
�,�t�J�,�
/�	0r�c��|tjdfvs|tjur;tjdt	|�j
�d�tt���|tjur�|tjur�|jdk(r|j�nd|fg}|D]�\}}t|�dkDs�|j�j}	|	tj|	�d}	|	j�s�Ytjdt	|�j
�d�tt���nd	}|tjurd}|j!|j#d
d��}
|�|}n|j%||
|��}|j&d|||
d
�|��}||zdz
}
|�9|
j(|
j*j-�}
|
j/|�}
|
j1|d��S)a�
        Fractional change between the current and a prior element.

        Computes the fractional change from the immediately previous row by
        default. This is useful in comparing the fraction of change in a time
        series of elements.

        .. note::

            Despite the name of this method, it calculates fractional change
            (also known as per unit change or relative change) and not
            percentage change. If you need the percentage change, multiply
            these values by 100.

        Parameters
        ----------
        periods : int, default 1
            Periods to shift for forming percent change.
        fill_method : {'backfill', 'bfill', 'pad', 'ffill', None}, default 'pad'
            How to handle NAs **before** computing percent changes.

            .. deprecated:: 2.1
                All options of `fill_method` are deprecated except `fill_method=None`.

        limit : int, default None
            The number of consecutive NAs to fill before stopping.

            .. deprecated:: 2.1

        freq : DateOffset, timedelta, or str, optional
            Increment to use from time series API (e.g. 'ME' or BDay()).
        **kwargs
            Additional keyword arguments are passed into
            `DataFrame.shift` or `Series.shift`.

        Returns
        -------
        Series or DataFrame
            The same type as the calling object.

        See Also
        --------
        Series.diff : Compute the difference of two elements in a Series.
        DataFrame.diff : Compute the difference of two elements in a DataFrame.
        Series.shift : Shift the index by some number of periods.
        DataFrame.shift : Shift the index by some number of periods.

        Examples
        --------
        **Series**

        >>> s = pd.Series([90, 91, 85])
        >>> s
        0    90
        1    91
        2    85
        dtype: int64

        >>> s.pct_change()
        0         NaN
        1    0.011111
        2   -0.065934
        dtype: float64

        >>> s.pct_change(periods=2)
        0         NaN
        1         NaN
        2   -0.055556
        dtype: float64

        See the percentage change in a Series where filling NAs with last
        valid observation forward to next valid.

        >>> s = pd.Series([90, 91, None, 85])
        >>> s
        0    90.0
        1    91.0
        2     NaN
        3    85.0
        dtype: float64

        >>> s.ffill().pct_change()
        0         NaN
        1    0.011111
        2    0.000000
        3   -0.065934
        dtype: float64

        **DataFrame**

        Percentage change in French franc, Deutsche Mark, and Italian lira from
        1980-01-01 to 1980-03-01.

        >>> df = pd.DataFrame({
        ...     'FR': [4.0405, 4.0963, 4.3149],
        ...     'GR': [1.7246, 1.7482, 1.8519],
        ...     'IT': [804.74, 810.01, 860.13]},
        ...     index=['1980-01-01', '1980-02-01', '1980-03-01'])
        >>> df
                        FR      GR      IT
        1980-01-01  4.0405  1.7246  804.74
        1980-02-01  4.0963  1.7482  810.01
        1980-03-01  4.3149  1.8519  860.13

        >>> df.pct_change()
                          FR        GR        IT
        1980-01-01       NaN       NaN       NaN
        1980-02-01  0.013810  0.013684  0.006549
        1980-03-01  0.053365  0.059318  0.061876

        Percentage of change in GOOG and APPL stock volume. Shows computing
        the percentage change between columns.

        >>> df = pd.DataFrame({
        ...     '2016': [1769950, 30586265],
        ...     '2015': [1500923, 40912316],
        ...     '2014': [1371819, 41403351]},
        ...     index=['GOOG', 'APPL'])
        >>> df
                  2016      2015      2014
        GOOG   1769950   1500923   1371819
        APPL  30586265  40912316  41403351

        >>> df.pct_change(axis='columns', periods=-1)
                  2016      2015  2014
        GOOG  0.179241  0.094112   NaN
        APPL -0.252395 -0.011860   NaN
        NzDThe 'fill_method' keyword being not None and the 'limit' keyword in z�.pct_change are deprecated and will be removed in a future version. Either fill in any non-leading NA values prior to calling pct_change or specify 'fill_method=None' to not fill NA values.r�rrz!The default fill_method='pad' in z�.pct_change is deprecated and will be removed in a future version. Either fill in any non-leading NA values prior to calling pct_change or specify 'fill_method=None' to not fill NA values.r!r�rr�)r�rKr�r��
pct_changerart)rr�r�r�rr�rcrUrr�r�ror�rO�argmaxr�rrwrr�rr�
duplicatedr6r�)r�r��fill_methodr3rKrrJr�r�rLr�r��shiftedr�s              r�r)zNDFrame.pct_change�.s���T�s�~�~�t�4�4��S�^�^�8S��M�M�V���:�&�&�'�(��
�+�-�
��#�.�.�(�����&�'+�y�y�A�~�t�z�z�|�T�4�L�>��"�F�A�s��3�x�!�|�"�x�x�z�0�0��#�B�I�I�t�e�$4�$6�7���8�8�:�$�M�M� C�#'��:�#6�#6�"7�8W�!W�
!.�+;�+=��"�#� �K��C�N�N�"��E��$�$�V�Z�Z���%@�A�����D��(�(��4�u�(�M�D��$�*�*�M�W�4�d�M�f�M��
�G�^�a�
����������,�,�.�.�/�B�����&�B����t�L��9�9r�c��tjd||��t|dd��|jdkDr0|�.|j||fd||d�|��}|j||fd|i|��S|�d}|jdkDrw|dk(rrt|jj�dkDrPtd	�|jjD��r*|s(|}|r|j�}|j|||�
�S|j|||||d��S)
Nrt��fname�skipnaF��none_allowedr�r)r��	bool_onlyr1c3�:K�|]}|jdk(���y�w)rN)rr�s  r�rIz(NDFrame._logical_func.<locals>.<genexpr>�/s����:�)9�A�A�F�F�a�K�)9�s��r1r�)r(r�r1r��filter_type)r��validate_logical_funcrXr�
_logical_funcr�r�r�r�r��
_reduce_axis1�_reduce)	r�r(r�r�r4r1rr�r�s	         r�r9zNDFrame._logical_func�/s2��	� � ��V�4�8��F�H�5�A��9�9�q�=�T�\�$�$�$�$��d��!"�i���JP��C�%�3�$�$��d��#)��-3��
��\��D�
�I�I��M���	��D�I�I�$�$�%��)��:����)9�)9�:�:���C���)�)�+���$�$�T�4��$�?�?��|�|�����"��
�
�	
r�c�L�|jdtj|||fi|��S)Nr�)r9rv�nanany�r�r�r4r1rs     r�r�zNDFrame.any�/�0��"�t�!�!��6�=�=�$�	�6�
�=C�
�	
r�c�L�|jdtj|||fi|��S)Nr�)r9rv�nanallr>s     r�r�zNDFrame.all�/r?r�c�n�����tj�|����|�d}n|j|�}|dk(r.|jj��g|��d�d����jS����fd�}|j
j
|�}|j||j��j|���S)Nrr�)r�r1c����t|d�r|jn|}t|t�r|j�fd�i���}ntj|����}t|d�r|j}|S|}|S)Nr=r1r6)rsr=r�ry�_accumulaterv�
na_accum_func)�
blk_valuesr�rvr�rr(r1s   ����r��block_accum_funcz-NDFrame._accum_func.<locals>.block_accum_func�/sw���%,�Z��%=�Z�\�\�:�F��&�.�1�+��+�+�D�J��J�6�J���-�-�f�d�6�J��!(���!5�V�X�X�F��M�<B�F��Mr�r�ra)
r��validate_cum_func_with_skipnarr=�_accum_funcr�r�r�r�r�)	r�r(r�r�r1r�rrGrvs	 `` ` `  r�rIzNDFrame._accum_func�/s�����1�1�&�$���M���<��D��(�(��.�D��1�9�%�4�6�6�%�%��d��48��!"�6��<B���a�
�
	������!1�2���)�)�&�v�{�{�)�C�P�P���Q�
�	
r�c�d�|jdtjj||g|��i|��S)N�cummax)rIrO�maximum�
accumulate�r�r�r1r�rs     r�rKzNDFrame.cummax�/�:���t����b�j�j�+�+�T�6�
�<@�
�DJ�
�	
r�c�d�|jdtjj||g|��i|��S)N�cummin)rIrO�minimumrMrNs     r�rQzNDFrame.cummin�/rOr�c�P�|jdtj||g|��i|��S)N�cumsum)rIrOrTrNs     r�rTzNDFrame.cumsum0s)���t����"�)�)�T�6�S�D�S�F�S�Sr�c�P�|jdtj||g|��i|��S)N�cumprod)rIrOrVrNs     r�rVzNDFrame.cumprod0s)���t���	�2�:�:�t�V�U�d�U�f�U�Ur�c�H�tjd||��t|dd��|�P|jdkDr>t	j
dt
|�j�d|�d	�tt��
�d}n|tjurd}|j||||||��S)
Nrtr/r1Fr2r��The behavior of �.�� with axis=None is deprecated, in a future version this will reduce over both axes and return a scalar. To retain the old behavior, pass axis=0 (or do not pass axis)r�r)r�r�r1�ddof)
r��validate_stat_ddof_funcrXrr�r�rr�rcrUrr�r;)r�r(r�r�r1r[r�rs        r��_stat_function_ddofzNDFrame._stat_function_ddof0s���	�"�"�2�v�T�:��F�H�5�A��<��y�y�1�}��
�
�&�t�D�z�':�':�&;�1�T�F�C3�3�"�/�1�
��D�
�S�^�^�
#��D��|�|��$�T��V�RV��
�	
r�c�N�|jdtj||||fi|��S)N�sem)r]rv�nansem�r�r�r1r[r�rs      r�r_zNDFrame.sem&0�2��(�t�'�'��6�=�=�$���l�
�FL�
�	
r�c�N�|jdtj||||fi|��S)N�var)r]rv�nanvarras      r�rdzNDFrame.var20rbr�c�N�|jdtj||||fi|��S)N�std)r]rv�nanstdras      r�rgzNDFrame.std>0rbr�c��|dvsJ|��tj|d|�t|dd��|j|||||��S)N)�median�meanrurv�kurt�skewrtr1Fr2)r(r�r1r�)r��
validate_funcrXr;)r�r(r�r�r1r�rs       r��_stat_functionzNDFrame._stat_functionJ0sW���G�G�M��M�G�
����r�6�*��F�H�5�A��|�|��t�$�v�L��
�	
r�c�L�|jdtj|||fi|��S)Nru)rorv�nanmin�r�r�r1r�rs     r�ruzNDFrame.min]0�6��#�t�"�"���M�M����
��

�	
r�c�L�|jdtj|||fi|��S)Nrv)rorv�nanmaxrrs     r�rvzNDFrame.maxm0rsr�c�L�|jdtj|||fi|��S)Nrk)rorv�nanmeanrrs     r�rkzNDFrame.mean}0�0��#�t�"�"��F�N�N�D�&�,�
�BH�
�	
r�c�L�|jdtj|||fi|��S)Nrj)rorv�	nanmedianrrs     r�rjzNDFrame.median�0s2��#�t�"�"��f�&�&��f�l�
�FL�
�	
r�c�L�|jdtj|||fi|��S)Nrm)rorv�nanskewrrs     r�rmzNDFrame.skew�0rxr�c�L�|jdtj|||fi|��S)Nrl)rorv�nankurtrrs     r�rlzNDFrame.kurt�0rxr�c�\�|dvsJ|��tj|d|�t|dd��|�P|jdkDr>t	j
dt
|�j�d|�d	�tt��
�d}n|tjurd}|j||||||��S)
N)�sumrPrtr1Fr2r�rXrYrZr�r)r(r�r1r��	min_count)
r�rnrXrr�r�rr�rcrUrr�r;)r�r(r�r�r1r�r�rs        r��_min_count_stat_functionz NDFrame._min_count_stat_function�0s�����&�,��,�&�
����r�6�*��F�H�5�A��<��y�y�1�}��
�
�&�t�D�z�':�':�&;�1�T�F�C3�3�"�/�1�
��D�
�S�^�^�
#��D��|�|�����%��
�
�	
r�c�N�|jdtj||||fi|��S)Nr�)r�rv�nansum�r�r�r1r�r�rs      r�r�zNDFrame.sum�0s2��-�t�,�,��6�=�=�$���i�
�KQ�
�	
r�c�N�|jdtj||||fi|��S)NrP)r�rv�nanprodr�s      r�rPzNDFrame.prod�0s9��-�t�,�,���N�N�����

��
�	
r��singlec
��|tjur�|j|�}d}
|dk(rBtjdt|�j�d|
�d|
�d�tt���nAtjdt|�j�d|
�d	�tt���nd
}|�t||||||||||	��
St||||||||||	��
S)N�rollingr��Support for axis=1 in rY�B is deprecated and will be removed in a future version. Use obj.T.�
(...) insteadr�r��i is deprecated and will be removed in a future version. Call the method without the axis keyword instead.r)	�window�min_periods�center�win_typer�r�r�r�rb)rr�rr�r�rr�rcrUr�r�)r�r�r�r�r�r�r�r�r�rbr(s           r�r�zNDFrame.rolling�0s���s�~�~�%��(�(��.�D��D��q�y��
�
�,�T�$�Z�-@�-@�,A��4�&�I!�!%��m�5�"�/�1���
�
�,�T�$�Z�-@�-@�,A��4�&�IH�H�"�/�1���D������'��!�������
����#��������
�	
r�c	�z�|tjur�|j|�}d}|dk(rBtjdt|�j�d|�d|�d�tt���nAtjdt|�j�d|�d	�tt���nd
}t||||��S)N�	expandingr�r�rYr�r�r�r�r�r)r�r�rb)
rr�rr�r�rr�rcrUr�)r�r�r�rbr(s     r�r�zNDFrame.expanding11s����s�~�~�%��(�(��.�D��D��q�y��
�
�,�T�$�Z�-@�-@�,A��4�&�I!�!%��m�5�"�/�1���
�
�,�T�$�Z�-@�-@�,A��4�&�IH�H�"�/�1���D���;�T�&�Q�Qr�c
��|tjur�|j|�}d}|dk(rBtjdt|�j�d|�d|�d�tt���nAtjdt|�j�d|�d	�tt���nd
}t||||||||||	|
��S)N�ewmr�r�rYr�r�r�r�r�r)
�com�span�halflife�alphar��adjust�	ignore_nar��timesrb)
rr�rr�r�rr�rcrUr�)r�r�r�r�r�r�r�r�r�r�rbr(s            r�r�zNDFrame.ewmP1s����s�~�~�%��(�(��.�D��D��q�y��
�
�,�T�$�Z�-@�-@�,A��4�&�I!�!%��m�5�"�/�1���
�
�,�T�$�Z�-@�-@�,A��4�&�IH�H�"�/�1���D�&������#������
�	
r�c���d}ts+t�r!tj|�tdzkrd}|||�}|j
dk(rs|j
|�rb|j|jk(rIt�s?t�r|r3|jjtd�|j|��|S|j�|j|j|d��d��|S)	z<
        Wrap arithmetic method to operate inplace.
        TrFr�N)r�r)r�)rGrr	r
rHrr�r�rr��setitem_inplacerzrfr�r�r6)r�r��opr�rvs     r��_inplace_methodzNDFrame._inplace_method�1s���
���*�,����t�$�	�A�
�5����D�%���
�I�I��N��$�$�T�*�����
�
�*�'�)�'�)�$�

�I�I�%�%��d��V�^�^�$�
&�
��K�	
����	
�������5��1�%�	�	
��r�c�L�|j|t|�j�Sr�)r�r�__add__r�s  r��__iadd__zNDFrame.__iadd__�1�!���#�#�E�4��:�+=�+=�>�>r�c�L�|j|t|�j�Sr�)r�r�__sub__r�s  r��__isub__zNDFrame.__isub__�1r�r�c�L�|j|t|�j�Sr�)r�r�__mul__r�s  r��__imul__zNDFrame.__imul__�1r�r�c�L�|j|t|�j�Sr�)r�r�__truediv__r�s  r��__itruediv__zNDFrame.__itruediv__�1s&���#�#��4��:�)�)�
�	
r�c�L�|j|t|�j�Sr�)r�r�__floordiv__r�s  r��
__ifloordiv__zNDFrame.__ifloordiv__�1s&���#�#��4��:�*�*�
�	
r�c�L�|j|t|�j�Sr�)r�r�__mod__r�s  r��__imod__zNDFrame.__imod__�1r�r�c�L�|j|t|�j�Sr�)r�r�__pow__r�s  r��__ipow__zNDFrame.__ipow__�1r�r�c�L�|j|t|�j�Sr�)r�r�__and__r�s  r��__iand__zNDFrame.__iand__�1r�r�c�L�|j|t|�j�Sr�)r�r�__or__r�s  r��__ior__zNDFrame.__ior__�1s���#�#�E�4��:�+<�+<�=�=r�c�L�|j|t|�j�Sr�)r�r�__xor__r�s  r��__ixor__zNDFrame.__ixor__�1r�r�c�t�|j�j}t||��}|�y|j|S)a
        Retrieves the index of the first valid value.

        Parameters
        ----------
        how : {'first', 'last'}
            Use this parameter to change between the first or last valid index.

        Returns
        -------
        idx_first_valid : type of index
        )r|�is_validN)rpr�r�r)r�r|r��idxposs    r��_find_valid_indexzNDFrame._find_valid_index�1s8���:�:�<�&�&��!�c�H�=���>���z�z�&�!�!r�r�)r�r�c�&�|jd��S)am
        Return index for {position} non-NA value or None, if no non-NA value is found.

        Returns
        -------
        type of index

        Examples
        --------
        For Series:

        >>> s = pd.Series([None, 3, 4])
        >>> s.first_valid_index()
        1
        >>> s.last_valid_index()
        2

        >>> s = pd.Series([None, None])
        >>> print(s.first_valid_index())
        None
        >>> print(s.last_valid_index())
        None

        If all elements in Series are NA/null, returns None.

        >>> s = pd.Series()
        >>> print(s.first_valid_index())
        None
        >>> print(s.last_valid_index())
        None

        If Series is empty, returns None.

        For DataFrame:

        >>> df = pd.DataFrame({{'A': [None, None, 2], 'B': [None, 3, 4]}})
        >>> df
             A      B
        0  NaN    NaN
        1  NaN    3.0
        2  2.0    4.0
        >>> df.first_valid_index()
        1
        >>> df.last_valid_index()
        2

        >>> df = pd.DataFrame({{'A': [None, None, None], 'B': [None, None, None]}})
        >>> df
             A      B
        0  None   None
        1  None   None
        2  None   None
        >>> print(df.first_valid_index())
        None
        >>> print(df.last_valid_index())
        None

        If all elements in DataFrame are NA/null, returns None.

        >>> df = pd.DataFrame()
        >>> df
        Empty DataFrame
        Columns: []
        Index: []
        >>> print(df.first_valid_index())
        None
        >>> print(df.last_valid_index())
        None

        If DataFrame is empty, returns None.
        r��r|�r�r�s r��first_valid_indexzNDFrame.first_valid_index�1s��T�%�%�'�%�2�2r�c�&�|jd��S)Nrar�r�r�s r��last_valid_indexzNDFrame.last_valid_indexD2s���%�%�&�%�1�1r�)r�r0r�r�)NF)
r�r0r�z.dict[Literal['index', 'columns'], Axes | None]r��DtypeObj | Noner�r�r�r0)T)r�r�r�r�r�r8)r�r0r��list[Index]r�r8)r�r�)r�zMapping[Hashable, Any]r�r�)r�r|)r�r�r��
bool_t | Noner�r8)r�r�)r�zCallable[..., Self]r�)r�zSequence[Axis] | None)r�rr�r)r�rr�r	)r�rr�r~)r�r�r�zdict[str, Series | MultiIndex])r�z#dict[Hashable, Series | MultiIndex])r�zdict[Hashable, Series])r�r~)r�ztuple[int, ...])r�r�)r�r)r�rr�r�r�r8)r�rr�r�r�r�)r�rrUzAnyArrayLike | listr�r�)rirrjrr�r�r�r8)r)r*r+r�rr�r8)rur�r�zSeries | Any)r��Axis | None)r��Renamer | Nonerr�rr�r�r�r�r�r�r�r*�Level | Noner~r�r��Self | None).)
r��IndexLabel | lib.NoDefaultr�rr�r�r��Literal[False]r�r8)
r�r�r�rr�r�r��
Literal[True]r�r�)
r�r�r�rr�r�r�r�r�r�)rFTr�)r�r�r�r�)r�r8)r�r)r�rr�r8)r)r/r�rr�r�)r)r/r�rr�r�)r)r/r�rr�r�)r)r/r�rr�r)r�r)r�r�r�)r�znpt.DTypeLike | Noner�r�r�z
np.ndarray)rznp.ufuncrbr�rrrr)r�zdict[str, Any]r�)r�r�)�Sheet1r�NNTTNrrNTriNNN)"rAz)FilePath | WriteExcelBuffer | ExcelWriterrPr�rIr�rL�
str | Noner�Sequence[Hashable] | NonerKzSequence[Hashable] | bool_trr�rM�IndexLabel | NonerQrrRrrTz(Literal['openpyxl', 'xlsxwriter'] | NonerNr�rOr�rSztuple[int, int] | NonerE�StorageOptions | NonerUzdict[str, Any] | Noner�r�)
NNN�
T�msNFr\NNN�w)rZ�7FilePath | WriteBuffer[bytes] | WriteBuffer[str] | Noner9zILiteral['split', 'records', 'index', 'table', 'columns', 'values'] | Nonerar�rbrrcr�rdrBrez(Callable[[Any], JSONSerializable] | Nonerfr�rgr rr�rh�
int | NonerEr�rizLiteral['a', 'w']r�r�)r�NNFNTNNNN�strictzUTF-8)rZzFilePath | HDFStorer)r�rizLiteral['a', 'w', 'r+']ror�rpz/Literal['zlib', 'lzo', 'bzip2', 'blosc'] | Nonerqr�rrz Literal['fixed', 'table'] | Nonerr�rszint | dict[str, int] | Nonerur�rvz Literal[True] | list[str] | Noner~r3rwr�r�r�)N�failTNNNN)r(r�r|r�r}z$Literal['fail', 'replace', 'append']rr�rMr�r~r�r�zDtypeArg | Nonerbz"Literal['multi'] | Callable | Noner�r�)
rzFilePath | WriteBuffer[bytes]rgr r�rrEr�r�r�)TN)r�r�r�r�r�r�).....................),r�r�rr�rK�bool_t | SequenceNotStr[str]rr�rIr�r��FormattersType | NonerL�FloatFormatType | Noner�r�r�r�r�r�r�r�r�r�r�r�rwr�r�r�r�r�r�r�r�r�r��str | tuple[str, str] | Noner�r�r�r�r�r�)....................),r�zFilePath | WriteBuffer[str]rr�rKr�rr�rIr�r�r�rLr�r�r�r�r�r�r�r�r�r�r�r�r�rwr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�)NNTT�NaNNNNTFNNNNrYNNNNNN),r�z"FilePath | WriteBuffer[str] | Nonerr�rKr�rr�rIr�r�r�rLr�r�r�r�r�r�r�r�r�r�r�r�r�rwr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�)
r��dict | list[dict] | Noner�r�rrr�r�r�r��dict | None),rZr�r�r�rIr�rL�str | Callable | Nonerr�rK�bool_t | list[str]rr�rMr�rir�rwr�rgr r�r�r�r�r�r�r~r�rar�r�r�r�r�r�r�r~r3rEr;r�r�),rZz0FilePath | WriteBuffer[bytes] | WriteBuffer[str]r�r�rIr�rLr�rr�rKr�rr�rMr�rir�rwr�rgr r�r�r�r�r�r�r~r�rar�r�r�r�r�r�r�r~r3rEr;r�r�)Nr*r�NNTTNr�Nr\NrNNNTNrYr�N),rZr�r�r�rIr�rLr�rr�rKr�rr�rMr�rir�rwr�rgr r�r�r�r�r�r�r~r�rar�r�r�r�r�r�r�r~r3rEr�r�r�)FTF)r�r�r�r�r�r�r�r�)r�rr�r8)rNT)
r)r+r�rr*r�rr�r�r8)r)rzr�r8)rrzr�rr�r8)rr�r�r�r�r�)�settingF)r�r�r$r�)r�r�)NNNN)rbz>Literal['backfill', 'bfill', 'pad', 'ffill', 'nearest'] | Noner�r�r3r�r�r8)rUr+r�rrr+rr+r*r�r�r�r~r)r�r�)rUr+r�rrr+rr+r*r�r�r�r~r)r�r8)rUr+r�rrr+rr+r*r�r�r�r~r)r�r�)rUr�r�rrr�rr�r*r�r�r�r~r)r�r�)Nr�F)r~r)rAr�r�r8)r�r�r�r�)r&r�r�r�r�r8)rVr�r�r�r�r8)r�rrX�bool_t | Sequence[bool_t]r�r�r�r:rYr1rZr�r)rCr�r8)r�rrXr�r�r�r�r:rYr1rZr�r)rCr�r�)r�rrXr�r�r�r�r:rYr1rZr�r)rCr�r�)r�rrXr�r�r�r�r:rYr1rZr�r)zValueKeyFunc | Noner�r�)r�rr*r+rXr�r�r�r�r:rYr1rcr�rZr�r)r*r�r�)r�rr*r+rXr�r�r�r�r:rYr1rcr�rZr�r)r*r�r8)r�rr*r+rXr�r�r�r�r:rYr1rcr�rZr�r)r*r�r�)r�rr*r�rXr�r�r�r�r:rYr1rcr�rZr�r)zIndexKeyFunc | Noner�r�)r�r�rbzReindexMethod | Noner�r�r*r�ro�
Scalar | Noner3r�r�r8)
r*r�r3r�ror�r�r�r�r8)r*r�r�r�)NFF)r�r�r@r�r�r8)r�r�r�r�r�r�r�r8)�)r�rr�r8)NNFNNNF)r�r�r��float | Noner�r�r�zRandomState | Noner�r�rZr�r�r8)r�z/Callable[..., T] | tuple[Callable[..., T], str]r�r=)rbr�r�r8)r(r�)r(r�r�r�)r�r�)r�r)Nr�)r�r�r~r)r�r8)r�r�r�r8)r�r�r�r8)r�r�r�r8)TTTTT�numpy_nullable)r�r�r�r�r�r�r�r�r�r�r�r"r�r8)r�r�)rbz,Literal['ffill', 'bfill', 'pad', 'backfill']r��None | Axisr�r�r3�
None | intr��#Literal['inside', 'outside'] | Noner�r�)r��'Hashable | Mapping | Series | DataFramerb�FillnaOptions | Noner�r�r�r�r3r�r�r�r�r8)r�r�rbr�r�r�r�r�r3r�r�r�r�r�)r�r�rbr�r�r�r�r�r3r�r�r�r�r�)r�z.Hashable | Mapping | Series | DataFrame | Nonerbr�r�r�r�r�r3r�r��dict | None | lib.NoDefaultr�r�)r�r�r�r�r3r�r�r�r�r�r�r8)r�r�r�r�r3r�r�r�r�r�r�r�)r�r�r�r�r3r�r�r�r�r�r�r�)
r�r�r�r�r3r�r�r�r�r�)
r�r�r�r�r3r�r�r�r�r�)..)
r�r�r3r�r�r�rb�0Literal['pad', 'ffill', 'bfill'] | lib.NoDefaultr�r8)
r�r�r3r�r�r�rbr�r�r�)
r�r�r3r�r�r�rbr�r�r�)rbr,r�rr3r�r�r�r<�-Literal['forward', 'backward', 'both'] | Noner�r�r��'Literal['infer'] | None | lib.NoDefaultr�r8)rbr,r�rr3r�r�r�r<r�r�r�r�r�r�r�)rbr,r�rr3r�r�r�r<r�r�r�r�r�r�r�)rD)F)r�r�r�r�r�r8)r�r�r�r�r�r�)r�r�r�r�r�r�)NNFN)rKr(rbr�r|zLiteral['start', 'end'] | Noner}r�ro�Hashable | Noner�r8)FN)rWr�r�r�r�r8)�bothN)r�r-r�r�r�r8)r��Axis | lib.NoDefaultr��Literal['right', 'left'] | Noner�r�r�z1Literal['start', 'end', 's', 'e'] | lib.NoDefaultr�z5Literal['timestamp', 'period'] | None | lib.NoDefaultr�r�r*r�r�zstr | TimestampConvertibleTypesr�z TimedeltaConvertibleTypes | Noner�r�r�r�)r�averageFr�TF)r�rrbz2Literal['average', 'min', 'max', 'first', 'dense']r�r�r�z Literal['keep', 'top', 'bottom']rXr�r�r�r�r8)r�FFr�)r�rr�r�r�r�r�r<)r�r2r.rr�r�r*r�r�r�ror�rb�$FillnaOptions | None | lib.NoDefaultr3�int | None | lib.NoDefaultr�r�r��Axis | None | lib.NoDefaultr�ztuple[Self, NDFrameT])r�NNNNNNr)r�r�r.rr�r�r�r�r3r�r�rr�z$tuple[Self, DataFrame, Index | None])r�r�r.rr�r�r�r�r3r�r�rr�z!tuple[Self, Series, Index | None])r�r�r�r�r�r�)r�r�r�r�r*r/r�r8)r�r�r�r�r*r/r�r�)r�r�r�r�r*r/r�r�)r�r�r�r�r*r�r�r�)
r�zint | Sequence[int]r�rror�rVr�r�zSelf | DataFrame)r�rr�rr�r8)r�r�r�r�r�r8)rNN)rNNr�r�)
r�rr�r�rr>rr@r�r8r�)r�rr,r�r3r�r�r8)
r(r�r�r�r4r�r1r�r��Series | bool_t)r�r�r4r�r1r�r�r)r�rr4r�r1r�r�r)NT)r(r�r�r�r1r�)r�r�r1r�)r(r�r�rr1r�r[rr�r�r��Series | float)rTr�F)
r�r�r1r�r[rr�r�r�r)rTF)r(r�r�r�r1r�r�r�)r�r�r1r�r�r�)r�r�r1r�r�r�r�r)
r(r�r�rr1r�r�r�r�r)rTFr)r�r�r1r�r�r�r�r)r�z3int | dt.timedelta | str | BaseOffset | BaseIndexerr�r�r�r�r�r�r�r�r�r�r�zIntervalClosedType | Noner�r�rbr�r�zWindow | Rolling)r�rr�r�rb�Literal['single', 'table']r�r�)r�r�r�r�r�z(float | TimedeltaConvertibleTypes | Noner�r�r�r�r�r�r�r�r�r�r�z&np.ndarray | DataFrame | Series | Nonerbrr�r�)r|r�r�r�)r�r�)�r��
__module__�__qualname__�__doc__r��__annotations__r$r�r��	frozensetr�r�r�r�r�classmethodr�r�r��propertyr��setterr�r�r�r�rrrrrr
r�r.r6r=r?rCrKr�rrQrVrTr\r`rT�_shared_doc_kwargsrqrwr{r�rr�rr�r�r�r�r�r�r�r��__bool__r�r�r�r�r�r�r�r�r�rrr�r�r
rrrrrr"r'r1r6r@rSr�rBr<rlry�pickle�HIGHEST_PROTOCOLr�r�r�r5r�r�r�r�r[r�r�r�rrrr�r r�r+r�rerr6r�r>r�rSrWr]rfrOrQr5rursrtrwr�r;r�rwr�r�r�r�r�r�r�r�r�r�r�r�rfr<r�r�r�r�r�r�r�rr�rr!r$r)r�r?rWror[rpr_rdrlror{r�r�r�r�rar�r�r�r�r�r�rrLr�r�rrrr'r)r9r�r�rIrKrQrTrVr]r_rdrgrorurvrkrjrmrl�kurtosisr�r�rP�productr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__)r�s@r�r�r��s�?���	�	"�O�Y�	�%(��$8���8��5�J�� �$-�b�M�M�>�1��I�y��<@�H�9�@�
�M���

�I�
V���
"&���
��=���	�
��
�
����:�Y��Y�,������,�#��#�J�\�\�"��"��
�%���%�N��15�	>��>�"/�	>�

�>��>�@������"�(��(��
�
���
�4�3�45��1�0M��-�M���0�0��N�
������U���U���-���-��@��@�
����������<�Y��Y��
��
�,�
�3���3�8��H��H��>��>��
�����,�
�(���(�8�"�.N��	.N�
�.N�
�
.N�`�
� �
�+1�
�9F�
��
��!��!��=0��=0�~��!�'�*�+�=?�,��=?�~��p��p�j�"&�E>�!%�"&� �"��"��E>��E>��	E>�
 �E>��
E>��E>��E>��E>��E>�
�E>��E>�N�.1�
����!�"%�
�*�
��
��
� �
�
�
��
��.1�
����!�
�*�
��
��
��
�
�
��
��.1�
����!��
�*�
��
��
��
�
�
��
�.1�^�^�y��n�n�����"��y�*�y��
y��y��y�
�y�v�SW�A��A�-3�A�CP�A��A�L�
��
�
�Q,��Q,�l�8��8�"�8��8��;��;��
��
��H�
�@��@�D�F
��F
�P�����K��K��
��
�<�
��
�:�
��
�0�)"��)"�V�:��:�x�I��I�b��%�(�2�$��&��&��9K��9K�@#���"�IM��)��8E��	��$�M��M�'*�M�58�M�DG�M��M��	
��	
��#6��#6�P1������
M��
M��#��V�^�$<�:��	��$�%6�7�%,��#��#'�-1�.2��)-���;?�"��/3�15�/3�#[
�?�[
��[
��	[
�
!�[
�+�
[
�,�[
��[
�'�[
��[
��[
�9�[
��[
��[
�-�[
� /�![
�"-�#[
�$
�%[
����[
�z�#��V�]�$;�)��	�$�%6�7�(�)>�?�-�O��PT��"&� "�"�"�DH��*1�#�!�15�"%�Y
�L�Y
��Y
�
 �Y
��
Y
��Y
��Y
�B�Y
��Y
�(�Y
��Y
��Y
�/�Y
� �Y
� 
�!Y
�	���Y
�v�#��V�]�$;�(��),� $�CG��37��48�� $�9=�!)��T
�(�T
��T
�&�	T
�
�T
�A�
T
��T
�1�T
��T
�2�T
��T
�7�T
��T
��T
� 
�!T
���T
�l�#��$;�(��"�:@��)-� $�!%�59�]
��]
��	]
�
8�]
��
]
�'�]
��]
��]
�3�]
�
�]
���]
�~�#��V�V�$4�;��	�$�%6�7�(�)>�?�&�H��+2��/�/�15�?
�+�?
�(�?
��	?
�
/�?
�
�
?
�	���?
�B�#��V�H�>��7;�FF��FF�)3�FF�	
�FF���FF�P�Q7��Q7�f��-0�/2���,/�/2�"%�!��$'�#&� #�"��%(�),�"%�03��"�-�
��+��-�	�
���
�*��-�� ������"��!������ �!�"#�#�$'�%�& �'�(.�)�*�+�,�-�.

�/���4�.1�/2���,/�/2�"%�!��$'�#&� #�"��%(�),�"%�03��"�-�
(��+��-�	�
���
�*��-�� ������"��!������ �!�"#�#�$'�%�& �'�(.�)�*�+�,�-�.
�/���4�#��V�U�O�*��
37�-1�/3���,0�/3�"&�"�!�$(�#'� $�#��%)�)-�"&�04� �#�-Z
�
/�Z
�+�Z
�-�	Z
�
�Z
��
Z
�*�Z
�-�Z
� �Z
��Z
��Z
�"�Z
�!�Z
��Z
��Z
� �!Z
�"#�#Z
�$'�%Z
�& �'Z
�(.�)Z
�*�+Z
�,�-Z
�.
�/Z
���Z
�x�
�A9�*.�26�+/�15�%)�A9�'�	A9�
0�A9�)�
A9�/�A9�#�A9��A9�F� ���.1�-0�%(��),��"�*-�!��%(� #�"%�!�!$��!$�*-�-������	�
,��+�
�#����'������(������#�� �!�" �#�$�%�&�'�(�)�*�+�,(�-�.

�/���4���.1�-0�%(��),��"�*-�!��%(� #�"%�!�!$��!$�*-�-�E�����	�
,��+�
�#����'������(������#�� �!�" �#�$�%�&�'�(�)�*�+�,(�-�.
�/���4�#��V�]�$;�(��	�$�%6�7�(�)>�?�-�O��PT���.2�-1�%)��)-��#�*1�"��%)� $�"&�"�!%��!)�15�-s
�L�s
��s
��	s
�
,�s
�+�
s
�#�s
��s
�'�s
��s
��s
�(�s
��s
��s
�#�s
� �!s
�" �#s
�$�%s
�&�'s
�(�)s
�*�+s
�,/�-s
�.
�/s
�	���s
�p(��!%��	%��%��%��	%�

�%�4(��p
��p
�d���� ��#'�!�q�
�q��q�!�	q�
�q�
�
q��q�f(��"��"�$�$�-��-�
��HT��HT�T�#��#�P�����8��8�t�
�!���!��RV�"� ��
y!�O�y!��	y!�
�y!�
�y!��y!�v�!����!�!�!�����	�
���
�������
�����!����!�!�"%�!�����	�
���
��� ����
�����!����!�!��!�����	�
���
�������
����%)�%��#'�%)�"��%�%�!�%��	%�
!�%�#�
%��%��%��%�
�%�N�
�%�"�
T)�
�T)��
T)�
�T)��T)�l�O��O�"�G&��G&�R�F&��F&�P��/2�"%��"%�"�����-�	�
 ���
� ������
������/2��"%�"�����-�	�
���
� ������
������/2���"%�"�����-�	�
���
� ������
���� �/3��$�"(�$�#'�V(��V(�-�	V(�
�V(��
V(� �V(��V(�!�V(�
�V(�p���/2��"%�!$�"��
��
��	
�
-�
��

��
� �
��
��
��
�
�
��
����/2�"%��"%�!$�"��
��
��	
�
-�
� �

��
� �
��
��
��
�
�
��
����/2���"%�!$�"��
��
��	
�
-�
��

��
� �
��
��
��
�
�
��
�$�#'�/3��$�"(�!%�$�#'�3B��3B�!�	3B�
-�3B��
3B��3B� �3B��3B��3B�!�3B�
�3B�j	� ��)����I/��� �'+�"�"�$&�F�F� ��I/��
I/�%�I/��I/��I/�"�I/��I/�
�I/�	�I/�V� �� ��	 �"� �� �
� �� �D	
�(���#�"�,
��	,
�
�,
�
�
,
��,
�`�� � �jL��jL��	jL�
�jL�
�
jL�X�J��J�X�N��N�`��!���+/� �$�S��S��S��	S�)�
S��S��S�
�S��S�j��!�'�*�+�g8�=�g8�

�g8�,��g8�X�-��-�^�3��3� �'6��'6�R���������%��%��

��

��
�
)���
)��Y��Y��Y��Y��(��(��(��(��W��W�<�GN�D"�(�D"�9D�D"�	
�D"��D"�L�X
��X
�t�$��$��$��$��:>��:>�x�!%�!%�"&�"&�#'�&6�S?��S?��S?� �	S?�
 �S?�!�
S?�$�S?�
�S?��S?�p� �
!�� �:>� $�'>�<�'>��	'>�
�'>��
'>�8�'>��'>��'>�R�:=�
�(+��"%�� #�
�6�
�%�	
�
�
� �
��
��
�
�
��
��:=�
�(+��� #�
�6�
�%�	
�
�
��
��
��
�
�
��
��:=�
�(+���� #�
�6�
�%�	
�
�
��
��
��
�
�
��
��� ��)�*�+<�=��AE�k>�(,� �� �03���k>�=�k>�%�	k>�
�k>��
k>��k>�.�k>�
�k>�	��
k>�Z	� �"%��:=�03�	��	� �		�
�	�8�
	�.�	�
�	��	�� ��:=�03�	��	��		�
�	�8�
	�.�	�
�	��	�� ���:=�03�	��	��		�
�	�8�
	�.�	�
�	��	��� ��)�*�+<�=��!�� �:>�03���u
��u
��	u
�
�u
�8�
u
�.�u
�
�u
�	��
u
�n��!�'�*�+�!�� �03���
V��V��	V�
�V�.�
V�
�V�,��V�@� �"%��:=�03�	��	� �		�
�	�8�
	�.�	�
�	��	�� ��03�
����	�
��.�
�
����� ���:=�03�	��	��		�
�	�8�
	�.�	�
�	��	��� ��)�*�+<�=��!�� �:>�03���@
��@
��	@
�
�@
�8�
@
�.�@
�
�@
�	��
@
�D��!�'�*�+�!�� �03���
V��V��	V�
�V�.�
V�
�V�,��V�@���
�
#&���CF�
�
 �
��
��
�A�
�
�
��
����
� ��CF�
�
�
��
��
�A�
�
�
��
����
�
���CF�
�
�
��
��
�A�
�
�
��
����Y�� ��)�"�9�-����n�n�F?�
 � ��CF�>�>�F?�
�F?��
F?��F?�A�F?�
�F?���F?�P�&)����"%�IL�:=�<?��"���	�
�� �
�G��8��:��
�����&)����IL�:=�<?��"���	�
���
�G��8��:��
�����&)�����IL�:=�<?��"���	�
���
�G��8��:��
�����&.�{C�� ��IM�:>�<?�N�N�{C�"�{C��	{C�
�{C��
{C�G�{C�8�{C�:�{C�
�{C��{C�@
�f2��f2�V	�!�'�*�+�<<�,�<<�|	��'��0�1�>�2�>�	�!�'�*�+�<>�,�<>�|	��(��1�2�@�3�@�����.�I��I�@���	�
 �"%�
	�
�	� �
	�
�	��	����	�
 �	�
�	��
	�
�	��	����	�
 ��
	�
�	��
	�
�	��	�����
!��
�
���
�
����B��!�'�*�+�(,�.2�!�&*�
z
��z
�%�z
�,�	z
�
�z
�$�
z
�
�z
�,��z
�x�6;��6;�p�
)/� �R;�&�	R;�
�R;�
�
R;��R;�h��!�'�*�+�&)�^�^�26�15�HK���FI�n�n��"�2=�37�"�P
�#�P
�0�	P
�
/�P
�F�
P
�D�P
�
�P
��P
�0�P
�1�P
��P
�
�P
�,��P
�d�P��P�d�M!��M!�^��EN�$�6<� ��Z��Z�C�Z��	Z�
4�Z��
Z��Z�
�Z��Z�x	��i�	 �(:�7�(C�D��"�"�!2�
L��L��	L�
�L��
L�E�L�\�� ��)�*�+<�=��"� �"�"�&*�7:�~�~�,/�N�N�*-�.�.�69�n�n�_��_��_��	_�
�_��
_�$�_�5�_�*�_�(�_�4�_�
�_�	��
_�B	�"� ��"��� ��5'��5'��5'��	5'��
5'��5'��5'�
.�5'��5'�n�"� ��"��� ��M'��M'��M'��	M'��
M'��M'��M'�
+�M'��M'�^��n�n�� ���U-��	U-�
�U-��U-��U-�n��	�
#&���	�
 �	��
	��	�
�	��	���	� ��	�
�	��
	��	�
�	��	���	�
���	�
�	��
	��	�
�	��	��� ��)�
��
����f�f�m>�
 � �"�m>�
�m>��
m>��m>�
�m>���m>�^��	�
#&���	�
 �	��
	��	�
�	��	���	� ��	�
�	��
	��	�
�	��	���	�
���	�
�	��
	��	�
�	��	���
� ��)�
��
��
��n�n�0
�
 � �"�0
�
�0
��
0
��0
�
�0
���0
�d	�!�'�*�+�()�
��"�~�~�!�
W:�$�W:��	W:�
�W:��
W:�
�W:�,�W:�r�!9��!9�F��� �"�j��	j�
�j�
�
j��j�X��!�'�*�+�DH�Y>��Y>�4A�Y>�	
�Y>�,��Y>�v��!�'�*�+���"�#*�'.�~?��~?�
�~?�!�
~?�%�~?�
�~?�,��~?�F����	v0�

�v0��v0�p��<?�N�N�,/�N�N�
�w:��w:�:�w:�*�	w:�
�w:��w:�r�
�!��
-
��-
��	-
�
�-
��
-
�
�-
��-
�b�!��		
��	
��	
��		
�
�
	
��!��		
��	
��	
��		
�
�
	
��
!��$
��$
��	$
�
�$
��$
�L
�

�
T�V��
-0�N�N���$�
��
�*�	
�
�
��

��
�
�
��
�B���$�

��

��

��	

�
�

�
�

����$�

��

��

��	

�
�

�
�

����$�

��

��

��	

�
�

�
�

��
��$�

��
��	
�
�
��

��
�(��$�	
��
��
��	
�$��$�	
��
��
��	
�$��$�		
��	
��	
��		
�
�
	
���$�		
��	
��	
��		
�
�
	
���$�		
��	
��	
��		
�
�
	
���$�		
��	
��	
��		
�
�
	
��H�
�
-0�N�N��$��$
��$
�*�	$
�
�$
��
$
��$
��$
�P��$��

��

��

��	

�
�

���$��
��
��
��	
�
�
�$�G�
���\�#'��#��%(�^�^�,0���;
�C�;
� �;
��	;
�
�;
�
�
;
�#�;
�*�;
��;
��;
�
�;
���;
�z���^��%(�^�^�-5�	R��R�#�R�+�	R�

�R���R�:��	 �!�!�!�=A�"�"#��!�%(�^�^�8<�-5�/
�
�/
��/
�;�	/
�
�/
� �
/
��/
��/
�#�/
�6�/
�+�/
�
!�/
�"��/
�h�#��#�J�?��?��?��?��?��?��
��
��
��
��?��?��?��?��?��?��>��>��?��?��"��"�&��'�!3�G�!<�=�H3�>��H3�T��	�V�3E�g�3N�O�2�P��2r�r�ac
{desc}

Parameters
----------
axis : {axis_descr}
    Axis for the function to be applied on.
    For `Series` this parameter is unused and defaults to 0.

    For DataFrames, specifying ``axis=None`` will apply the aggregation
    across both axes.

    .. versionadded:: 2.0.0

skipna : bool, default True
    Exclude NA/null values when computing the result.
numeric_only : bool, default False
    Include only float, int, boolean columns. Not implemented for Series.

{min_count}**kwargs
    Additional keyword arguments to be passed to the function.

Returns
-------
{name1} or scalar{see_also}{examples}
a�
{desc}

Parameters
----------
axis : {axis_descr}
    Axis for the function to be applied on.
    For `Series` this parameter is unused and defaults to 0.

    .. warning::

        The behavior of DataFrame.{name} with ``axis=None`` is deprecated,
        in a future version this will reduce over both axes and return a scalar
        To retain the old behavior, pass axis=0 (or do not pass axis).

    .. versionadded:: 2.0.0

skipna : bool, default True
    Exclude NA/null values when computing the result.
numeric_only : bool, default False
    Include only float, int, boolean columns. Not implemented for Series.

{min_count}**kwargs
    Additional keyword arguments to be passed to the function.

Returns
-------
{name1} or scalar{see_also}{examples}
a!
{desc}

Parameters
----------
axis : {axis_descr}
    For `Series` this parameter is unused and defaults to 0.

    .. warning::

        The behavior of DataFrame.{name} with ``axis=None`` is deprecated,
        in a future version this will reduce over both axes and return a scalar
        To retain the old behavior, pass axis=0 (or do not pass axis).

skipna : bool, default True
    Exclude NA/null values. If an entire row/column is NA, the result
    will be NA.
ddof : int, default 1
    Delta Degrees of Freedom. The divisor used in calculations is N - ddof,
    where N represents the number of elements.
numeric_only : bool, default False
    Include only float, int, boolean columns. Not implemented for Series.

Returns
-------
{name1} or {name2} (if level specified) {notes}{examples}
zg

Notes
-----
To have the same behaviour as `numpy.std`, use `ddof=0` (instead of the
default `ddof=1`)ay

Examples
--------
>>> df = pd.DataFrame({'person_id': [0, 1, 2, 3],
...                    'age': [21, 25, 62, 43],
...                    'height': [1.61, 1.87, 1.49, 2.01]}
...                   ).set_index('person_id')
>>> df
           age  height
person_id
0           21    1.61
1           25    1.87
2           62    1.49
3           43    2.01

The standard deviation of the columns can be found as follows:

>>> df.std()
age       18.786076
height     0.237417
dtype: float64

Alternatively, `ddof=0` can be set to normalize by N instead of N-1:

>>> df.std(ddof=0)
age       16.269219
height     0.205609
dtype: float64a?

Examples
--------
>>> df = pd.DataFrame({'person_id': [0, 1, 2, 3],
...                    'age': [21, 25, 62, 43],
...                    'height': [1.61, 1.87, 1.49, 2.01]}
...                   ).set_index('person_id')
>>> df
           age  height
person_id
0           21    1.61
1           25    1.87
2           62    1.49
3           43    2.01

>>> df.var()
age       352.916667
height      0.056367
dtype: float64

Alternatively, ``ddof=0`` can be set to normalize by N instead of N-1:

>>> df.var(ddof=0)
age       264.687500
height      0.042275
dtype: float64aA
{desc}

Parameters
----------
axis : {{0 or 'index', 1 or 'columns', None}}, default 0
    Indicate which axis or axes should be reduced. For `Series` this parameter
    is unused and defaults to 0.

    * 0 / 'index' : reduce the index, return a Series whose index is the
      original column labels.
    * 1 / 'columns' : reduce the columns, return a Series whose index is the
      original index.
    * None : reduce all axes, return a scalar.

bool_only : bool, default False
    Include only boolean columns. Not implemented for Series.
skipna : bool, default True
    Exclude NA/null values. If the entire row/column is NA and skipna is
    True, then the result will be {empty_value}, as for an empty row/column.
    If skipna is False, then NA are treated as True, because these are not
    equal to zero.
**kwargs : any, default None
    Additional keywords have no effect but might be accepted for
    compatibility with NumPy.

Returns
-------
{name1} or {name2}
    If level is specified, then, {name2} is returned; otherwise, {name1}
    is returned.

{see_also}
{examples}z�Return whether all elements are True, potentially over an axis.

Returns True unless there at least one element within a series or
along a Dataframe axis that is False or equivalent (e.g. zero or
empty).a�Examples
--------
**Series**

>>> pd.Series([True, True]).all()
True
>>> pd.Series([True, False]).all()
False
>>> pd.Series([], dtype="float64").all()
True
>>> pd.Series([np.nan]).all()
True
>>> pd.Series([np.nan]).all(skipna=False)
True

**DataFrames**

Create a dataframe from a dictionary.

>>> df = pd.DataFrame({'col1': [True, True], 'col2': [True, False]})
>>> df
   col1   col2
0  True   True
1  True  False

Default behaviour checks if values in each column all return True.

>>> df.all()
col1     True
col2    False
dtype: bool

Specify ``axis='columns'`` to check if values in each row all return True.

>>> df.all(axis='columns')
0     True
1    False
dtype: bool

Or ``axis=None`` for whether every value is True.

>>> df.all(axis=None)
False
z�See Also
--------
Series.all : Return True if all elements are True.
DataFrame.any : Return True if one (or more) elements are True.
aZ
Return cumulative {desc} over a DataFrame or Series axis.

Returns a DataFrame or Series of the same size containing the cumulative
{desc}.

Parameters
----------
axis : {{0 or 'index', 1 or 'columns'}}, default 0
    The index or the name of the axis. 0 is equivalent to None or 'index'.
    For `Series` this parameter is unused and defaults to 0.
skipna : bool, default True
    Exclude NA/null values. If an entire row/column is NA, the result
    will be NA.
*args, **kwargs
    Additional keywords have no effect but might be accepted for
    compatibility with NumPy.

Returns
-------
{name1} or {name2}
    Return cumulative {desc} of {name1} or {name2}.

See Also
--------
core.window.expanding.Expanding.{accum_func_name} : Similar functionality
    but ignores ``NaN`` values.
{name2}.{accum_func_name} : Return the {desc} over
    {name2} axis.
{name2}.cummax : Return cumulative maximum over {name2} axis.
{name2}.cummin : Return cumulative minimum over {name2} axis.
{name2}.cumsum : Return cumulative sum over {name2} axis.
{name2}.cumprod : Return cumulative product over {name2} axis.

{examples}a�Examples
--------
**Series**

>>> s = pd.Series([2, np.nan, 5, -1, 0])
>>> s
0    2.0
1    NaN
2    5.0
3   -1.0
4    0.0
dtype: float64

By default, NA values are ignored.

>>> s.cummin()
0    2.0
1    NaN
2    2.0
3   -1.0
4   -1.0
dtype: float64

To include NA values in the operation, use ``skipna=False``

>>> s.cummin(skipna=False)
0    2.0
1    NaN
2    NaN
3    NaN
4    NaN
dtype: float64

**DataFrame**

>>> df = pd.DataFrame([[2.0, 1.0],
...                    [3.0, np.nan],
...                    [1.0, 0.0]],
...                   columns=list('AB'))
>>> df
     A    B
0  2.0  1.0
1  3.0  NaN
2  1.0  0.0

By default, iterates over rows and finds the minimum
in each column. This is equivalent to ``axis=None`` or ``axis='index'``.

>>> df.cummin()
     A    B
0  2.0  1.0
1  2.0  NaN
2  1.0  0.0

To iterate over columns and find the minimum in each row,
use ``axis=1``

>>> df.cummin(axis=1)
     A    B
0  2.0  1.0
1  3.0  NaN
2  1.0  0.0
a�Examples
--------
**Series**

>>> s = pd.Series([2, np.nan, 5, -1, 0])
>>> s
0    2.0
1    NaN
2    5.0
3   -1.0
4    0.0
dtype: float64

By default, NA values are ignored.

>>> s.cumsum()
0    2.0
1    NaN
2    7.0
3    6.0
4    6.0
dtype: float64

To include NA values in the operation, use ``skipna=False``

>>> s.cumsum(skipna=False)
0    2.0
1    NaN
2    NaN
3    NaN
4    NaN
dtype: float64

**DataFrame**

>>> df = pd.DataFrame([[2.0, 1.0],
...                    [3.0, np.nan],
...                    [1.0, 0.0]],
...                   columns=list('AB'))
>>> df
     A    B
0  2.0  1.0
1  3.0  NaN
2  1.0  0.0

By default, iterates over rows and finds the sum
in each column. This is equivalent to ``axis=None`` or ``axis='index'``.

>>> df.cumsum()
     A    B
0  2.0  1.0
1  5.0  NaN
2  6.0  1.0

To iterate over columns and find the sum in each row,
use ``axis=1``

>>> df.cumsum(axis=1)
     A    B
0  2.0  3.0
1  3.0  NaN
2  1.0  1.0
a�Examples
--------
**Series**

>>> s = pd.Series([2, np.nan, 5, -1, 0])
>>> s
0    2.0
1    NaN
2    5.0
3   -1.0
4    0.0
dtype: float64

By default, NA values are ignored.

>>> s.cumprod()
0     2.0
1     NaN
2    10.0
3   -10.0
4    -0.0
dtype: float64

To include NA values in the operation, use ``skipna=False``

>>> s.cumprod(skipna=False)
0    2.0
1    NaN
2    NaN
3    NaN
4    NaN
dtype: float64

**DataFrame**

>>> df = pd.DataFrame([[2.0, 1.0],
...                    [3.0, np.nan],
...                    [1.0, 0.0]],
...                   columns=list('AB'))
>>> df
     A    B
0  2.0  1.0
1  3.0  NaN
2  1.0  0.0

By default, iterates over rows and finds the product
in each column. This is equivalent to ``axis=None`` or ``axis='index'``.

>>> df.cumprod()
     A    B
0  2.0  1.0
1  6.0  NaN
2  6.0  0.0

To iterate over columns and find the product in each row,
use ``axis=1``

>>> df.cumprod(axis=1)
     A    B
0  2.0  2.0
1  3.0  NaN
2  1.0  0.0
a�Examples
--------
**Series**

>>> s = pd.Series([2, np.nan, 5, -1, 0])
>>> s
0    2.0
1    NaN
2    5.0
3   -1.0
4    0.0
dtype: float64

By default, NA values are ignored.

>>> s.cummax()
0    2.0
1    NaN
2    5.0
3    5.0
4    5.0
dtype: float64

To include NA values in the operation, use ``skipna=False``

>>> s.cummax(skipna=False)
0    2.0
1    NaN
2    NaN
3    NaN
4    NaN
dtype: float64

**DataFrame**

>>> df = pd.DataFrame([[2.0, 1.0],
...                    [3.0, np.nan],
...                    [1.0, 0.0]],
...                   columns=list('AB'))
>>> df
     A    B
0  2.0  1.0
1  3.0  NaN
2  1.0  0.0

By default, iterates over rows and finds the maximum
in each column. This is equivalent to ``axis=None`` or ``axis='index'``.

>>> df.cummax()
     A    B
0  2.0  1.0
1  3.0  NaN
2  3.0  1.0

To iterate over columns and find the maximum in each row,
use ``axis=1``

>>> df.cummax(axis=1)
     A    B
0  2.0  2.0
1  3.0  NaN
2  1.0  1.0
a2See Also
--------
numpy.any : Numpy version of this method.
Series.any : Return whether any element is True.
Series.all : Return whether all elements are True.
DataFrame.any : Return whether any element is True over requested axis.
DataFrame.all : Return whether all elements are True over requested axis.
z�Return whether any element is True, potentially over an axis.

Returns False unless there is at least one element within a series or
along a Dataframe axis that is True or equivalent (e.g. non-zero or
non-empty).a\Examples
--------
**Series**

For Series input, the output is a scalar indicating whether any element
is True.

>>> pd.Series([False, False]).any()
False
>>> pd.Series([True, False]).any()
True
>>> pd.Series([], dtype="float64").any()
False
>>> pd.Series([np.nan]).any()
False
>>> pd.Series([np.nan]).any(skipna=False)
True

**DataFrame**

Whether each column contains at least one True element (the default).

>>> df = pd.DataFrame({"A": [1, 2], "B": [0, 2], "C": [0, 0]})
>>> df
   A  B  C
0  1  0  0
1  2  2  0

>>> df.any()
A     True
B     True
C    False
dtype: bool

Aggregating over the columns.

>>> df = pd.DataFrame({"A": [True, False], "B": [1, 2]})
>>> df
       A  B
0   True  1
1  False  2

>>> df.any(axis='columns')
0    True
1    True
dtype: bool

>>> df = pd.DataFrame({"A": [True, False], "B": [1, 0]})
>>> df
       A  B
0   True  1
1  False  0

>>> df.any(axis='columns')
0    True
1    False
dtype: bool

Aggregating over the entire DataFrame with ``axis=None``.

>>> df.any(axis=None)
True

`any` for an empty DataFrame is an empty Series.

>>> pd.DataFrame([]).any()
Series([], dtype: bool)
a�

Examples
--------
>>> idx = pd.MultiIndex.from_arrays([
...     ['warm', 'warm', 'cold', 'cold'],
...     ['dog', 'falcon', 'fish', 'spider']],
...     names=['blooded', 'animal'])
>>> s = pd.Series([4, 2, 0, 8], name='legs', index=idx)
>>> s
blooded  animal
warm     dog       4
         falcon    2
cold     fish      0
         spider    8
Name: legs, dtype: int64

>>> s.{stat_func}()
{default_output}�stat_func_exampler��Sum���)�	stat_func�verb�default_output�level_output_0�level_output_1a

By default, the sum of an empty or all-NA Series is ``0``.

>>> pd.Series([], dtype="float64").sum()  # min_count=0 is the default
0.0

This can be controlled with the ``min_count`` parameter. For example, if
you'd like the sum of an empty series to be NaN, pass ``min_count=1``.

>>> pd.Series([], dtype="float64").sum(min_count=1)
nan

Thanks to the ``skipna`` parameter, ``min_count`` handles all-NA and
empty series identically.

>>> pd.Series([np.nan]).sum()
0.0

>>> pd.Series([np.nan]).sum(min_count=1)
nanrv�Max�r��
_max_examplesru�Minr�
_min_examplesa

See Also
--------
Series.sum : Return the sum.
Series.min : Return the minimum.
Series.max : Return the maximum.
Series.idxmin : Return the index of the minimum.
Series.idxmax : Return the index of the maximum.
DataFrame.sum : Return the sum over the requested axis.
DataFrame.min : Return the minimum over the requested axis.
DataFrame.max : Return the maximum over the requested axis.
DataFrame.idxmin : Return the index of the minimum over the requested axis.
DataFrame.idxmax : Return the index of the maximum over the requested axis.a�

Examples
--------
By default, the product of an empty or all-NA Series is ``1``

>>> pd.Series([], dtype="float64").prod()
1.0

This can be controlled with the ``min_count`` parameter

>>> pd.Series([], dtype="float64").prod(min_count=1)
nan

Thanks to the ``skipna`` parameter, ``min_count`` handles all-NA and
empty series identically.

>>> pd.Series([np.nan]).prod()
1.0

>>> pd.Series([np.nan]).prod(min_count=1)
nanz�min_count : int, default 0
    The required number of valid values to perform the operation. If fewer than
    ``min_count`` non-NA values are present the result will be NA.
c��|dk(rd}d}d}nd}d}d}|dk(rt}t}t}t}dd	i}	�n�|d
k(rt}t}t
}t}ddi}	�n�|dk(rt}d
}t}t}ddi}	�ny|dk(rt}d}t}t}ddi}	�nZ|dk(rt}d}t}t}dti}	�n7|dk(rt}d}t}t}dti}	�n|dk(rt}d}d}d}ddi}	n�|dk(rt}d}d}d}ddi}	n�|dk(rt}d}t }d}ddi}	n�|dk(rt}d }t"}d}dt$i}	n�|d!k(rt}d"}d#}d}ddi}	n�|d$k(rt}d%}d}d&}ddi}	n�|d'k(rt}d(}d}d)}ddi}	nn|d*k(rt&}d}d}t(}d+di}	nT|d,k(rt&}d-}d}t*}d+di}	n:|d.k(rt&}d/}d}t,}d+di}	n |d0k(rt&}d1}d}t.}d+di}	nt0�|j2d3|||||||d2�|	��}
|
S)4zB
    Generate the docstring for a Series/DataFrame reduction.
    r��scalarr�z{index (0)}r�z{index (0), columns (1)}r��empty_valuer�r�r�ruz�Return the minimum of the values over the requested axis.

If you want the *index* of the minimum, use ``idxmin``. This is the equivalent of the ``numpy.ndarray`` method ``argmin``.r�r�rvz�Return the maximum of the values over the requested axis.

If you want the *index* of the maximum, use ``idxmax``. This is the equivalent of the ``numpy.ndarray`` method ``argmax``.r�zfReturn the sum of the values over the requested axis.

This is equivalent to the method ``numpy.sum``.rPz9Return the product of the values over the requested axis.rjz8Return the median of the values over the requested axis.a

            Examples
            --------
            >>> s = pd.Series([1, 2, 3])
            >>> s.median()
            2.0

            With a DataFrame

            >>> df = pd.DataFrame({'a': [1, 2], 'b': [2, 3]}, index=['tiger', 'zebra'])
            >>> df
                   a   b
            tiger  1   2
            zebra  2   3
            >>> df.median()
            a   1.5
            b   2.5
            dtype: float64

            Using axis=1

            >>> df.median(axis=1)
            tiger   1.5
            zebra   2.5
            dtype: float64

            In this case, `numeric_only` should be set to `True`
            to avoid getting an error.

            >>> df = pd.DataFrame({'a': [1, 2], 'b': ['T', 'Z']},
            ...                   index=['tiger', 'zebra'])
            >>> df.median(numeric_only=True)
            a   1.5
            dtype: float64rkz6Return the mean of the values over the requested axis.aw

            Examples
            --------
            >>> s = pd.Series([1, 2, 3])
            >>> s.mean()
            2.0

            With a DataFrame

            >>> df = pd.DataFrame({'a': [1, 2], 'b': [2, 3]}, index=['tiger', 'zebra'])
            >>> df
                   a   b
            tiger  1   2
            zebra  2   3
            >>> df.mean()
            a   1.5
            b   2.5
            dtype: float64

            Using axis=1

            >>> df.mean(axis=1)
            tiger   1.5
            zebra   2.5
            dtype: float64

            In this case, `numeric_only` should be set to `True` to avoid
            getting an error.

            >>> df = pd.DataFrame({'a': [1, 2], 'b': ['T', 'Z']},
            ...                   index=['tiger', 'zebra'])
            >>> df.mean(numeric_only=True)
            a   1.5
            dtype: float64rdzyReturn unbiased variance over requested axis.

Normalized by N-1 by default. This can be changed using the ddof argument.�notesrgz�Return sample standard deviation over requested axis.

Normalized by N-1 by default. This can be changed using the ddof argument.r_z�Return unbiased standard error of the mean over requested axis.

Normalized by N-1 by default. This can be changed using the ddof argumenta�

            Examples
            --------
            >>> s = pd.Series([1, 2, 3])
            >>> s.sem().round(6)
            0.57735

            With a DataFrame

            >>> df = pd.DataFrame({'a': [1, 2], 'b': [2, 3]}, index=['tiger', 'zebra'])
            >>> df
                   a   b
            tiger  1   2
            zebra  2   3
            >>> df.sem()
            a   0.5
            b   0.5
            dtype: float64

            Using axis=1

            >>> df.sem(axis=1)
            tiger   0.5
            zebra   0.5
            dtype: float64

            In this case, `numeric_only` should be set to `True`
            to avoid getting an error.

            >>> df = pd.DataFrame({'a': [1, 2], 'b': ['T', 'Z']},
            ...                   index=['tiger', 'zebra'])
            >>> df.sem(numeric_only=True)
            a   0.5
            dtype: float64rmz=Return unbiased skew over requested axis.

Normalized by N-1.a-

            Examples
            --------
            >>> s = pd.Series([1, 2, 3])
            >>> s.skew()
            0.0

            With a DataFrame

            >>> df = pd.DataFrame({'a': [1, 2, 3], 'b': [2, 3, 4], 'c': [1, 3, 5]},
            ...                   index=['tiger', 'zebra', 'cow'])
            >>> df
                    a   b   c
            tiger   1   2   1
            zebra   2   3   3
            cow     3   4   5
            >>> df.skew()
            a   0.0
            b   0.0
            c   0.0
            dtype: float64

            Using axis=1

            >>> df.skew(axis=1)
            tiger   1.732051
            zebra  -1.732051
            cow     0.000000
            dtype: float64

            In this case, `numeric_only` should be set to `True` to avoid
            getting an error.

            >>> df = pd.DataFrame({'a': [1, 2, 3], 'b': ['T', 'Z', 'X']},
            ...                   index=['tiger', 'zebra', 'cow'])
            >>> df.skew(numeric_only=True)
            a   0.0
            dtype: float64rlz�Return unbiased kurtosis over requested axis.

Kurtosis obtained using Fisher's definition of
kurtosis (kurtosis of normal == 0.0). Normalized by N-1.a6

            Examples
            --------
            >>> s = pd.Series([1, 2, 2, 3], index=['cat', 'dog', 'dog', 'mouse'])
            >>> s
            cat    1
            dog    2
            dog    2
            mouse  3
            dtype: int64
            >>> s.kurt()
            1.5

            With a DataFrame

            >>> df = pd.DataFrame({'a': [1, 2, 2, 3], 'b': [3, 4, 4, 4]},
            ...                   index=['cat', 'dog', 'dog', 'mouse'])
            >>> df
                   a   b
              cat  1   3
              dog  2   4
              dog  2   4
            mouse  3   4
            >>> df.kurt()
            a   1.5
            b   4.0
            dtype: float64

            With axis=None

            >>> df.kurt(axis=None).round(6)
            -0.988693

            Using axis=1

            >>> df = pd.DataFrame({'a': [1, 2], 'b': [3, 4], 'c': [3, 4], 'd': [1, 2]},
            ...                   index=['cat', 'dog'])
            >>> df.kurt(axis=1)
            cat   -6.0
            dog   -6.0
            dtype: float64rT�accum_func_namerVrrQrRrKrL)�descr(�name1�name2�
axis_descr�see_also�examplesrt)�	_bool_doc�	_any_desc�
_any_see_also�
_any_examples�	_all_desc�
_all_see_also�
_all_examples�_num_doc�_stat_func_see_alsor!r�
_sum_prod_doc�
_sum_examples�_min_count_stub�_prod_examples�
_num_ddof_doc�
_var_examples�
_std_examples�
_std_notes�	_cnum_doc�_cumsum_examples�_cumprod_examples�_cummin_examples�_cummax_examplesr�rr)r(rr(r)r*�base_docr'r+r,r�docstrs           r��make_docrE+5s/���q�y�����"�
�����/�
��u�}����� �� ����)��	
������� �� ����(��	
�����
I�	
�
'�� ���r�"��	
�����
I�	
�
'�� ���r�"��	
��� ��
>�	
�'�� ����/��	
��� ��J��&��!����/��	
��	���I����"��F�r�"��	
�����G����"��F�r�"��	
��� ��
K�	
�!�����2���	
��� ��
�	
�
!�����:�&��	
��� ��
&�	
�
"��F���2���	
�����P����&��N�r�"��	
�����
�	
���)��T�r�"��	
��	�������#��#�U�+��	
��	�������$��#�V�,��	
��	�������#��#�U�+��	
��	�������#��#�U�+��"�!�
�X�_�_�	�
�
������	��	�F��Mr�)r(r�rrr�r�)��
__future__rr=r�r�datetimer!�	functoolsrr"r^rr�rr�r	�typingrrr	r
rrr
rrr�r�numpyrO�pandas._configrrr�pandas._libsr�pandas._libs.libr�pandas._libs.tslibsrrrr�pandas._libs.tslibs.dtypesr�pandas._typingrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErF�
pandas.compatrG�pandas.compat._constantsrH�pandas.compat._optionalrI�pandas.compat.numpyrJr��
pandas.errorsrKrLrMrNrOrPrQrR�pandas.util._decoratorsrSrT�pandas.util._exceptionsrU�pandas.util._validatorsrVrWrXrYrZ�pandas.core.dtypes.astyper[�pandas.core.dtypes.commonr\r]r^r_r`rarbrcrdrerfrgrh�pandas.core.dtypes.dtypesrirj�pandas.core.dtypes.genericrkrl�pandas.core.dtypes.inferencermrn�pandas.core.dtypes.missingrorp�pandas.corerqr�rrrsrtrurvrw�pandas.core.array_algos.replacerx�pandas.core.arraysry�pandas.core.baserz�pandas.core.constructionr{�pandas.core.flagsr|�pandas.core.indexes.apir}r~rr�r�r�r��pandas.core.internalsr�r�r��"pandas.core.internals.constructionr�r��pandas.core.methods.describer��pandas.core.missingr�r�r��pandas.core.reshape.concatr��pandas.core.shared_docsr��pandas.core.sortingr��pandas.core.windowr�r�r�r��pandas.io.formats.formatr�r��pandas.io.formats.printingr��collections.abcr�r�r�r�r�r�r�r�r�r��pandas.core.indexers.objectsr�r~r�rr�r��
IndexingMixinr�r4r6r:r=r<r;r-r1r3r2r>rAr?r@rBr/r.r0rrr7rrr!r5r9r8rErtr�r��<module>rss*��"�����	���
�	�
�
�
�
�������-���>�.�.�.�.�.�.�.�.�.�.�.�.�^�.�>�.�	�	�	��5���5���������
���=�-�)�2�#������
�:���
.�0�3����4����/���9�.� �,����
�`�A�0�
��
��SE2�l�H�2�2�SE2�lJ��<�
�B�
�<�
��
�<�
�8!
�	�F
�	�,�
�\�
�"
�	�H?��B?��B?��B?��B�
�
�	�D�
�P�
���,�0�1�8�8��%��1�UV�9��
����
�,"�"5�6�=�=��%��!�TU�>��
�s��"�"5�6�=�=��%��!�TU�>��
�s��
O����.��]r�

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