� B�gz����dZddlmZddlmZddlZddlZddlmZddlm Z m Z m Z ddl Z ddl mZddlmZdd lmZmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddl m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-ddl.m/Z/ddl0m1Z1e rddl2m3Z3m4Z4ddl5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;ddlm<Z<ej=d��Z>e>fdbd�Z?dcd#�Z@ddd+�ZAGd,�d-��ZBGd.�d/eB��ZCded0�ZDd1d2iZEGd3�d4eB��ZFdfd6�ZGd7�ZHeFeFeCeCd8�ZIdgd<�ZJded=�ZKd>�ZLd?�ZMee%d(�@��dAddddddBdCddDdddEdEdejNddF�dhda���ZOdS)izW :mod:`pandas.io.html` is a module containing functionality for dealing with HTML IO. �)� annotations)�abcN)�Pattern)� TYPE_CHECKING�Literal�cast)�lib)�import_optional_dependency)�AbstractMethodError�EmptyDataError)�doc)�find_stack_level)�check_dtype_backend)� is_list_like��isna)�Index)� MultiIndex)�Series)� _shared_docs)� file_exists� get_handle� is_file_like� is_fsspec_url�is_url�stringify_path�validate_header_arg�� pprint_thing)� TextParser)�Iterable�Sequence)� BaseBuffer� DtypeBackend�FilePath� HTMLFlavors� ReadBuffer�StorageOptions)� DataFramez[\r\n]+|\s{2,}�s�str�regexr�returnc�R�|�d|�����S)a� Replace extra whitespace inside of a string with a single space. Parameters ---------- s : str or unicode The string from which to remove extra whitespace. regex : re.Pattern The regular expression to use to remove extra whitespace. Returns ------- subd : str or unicode `s` with all extra whitespace replaced with a single space. � )�sub�strip)r*r,s �^/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/pandas/io/html.py�_remove_whitespacer3Is �� �9�9�S�!�'�'�)�)� $� $�$��skiprows�"int | Sequence[int] | slice | None�int | Sequence[int]c�X�t|t��r5|jpd|jpd}}t t ||j|����St|tj��st|��rtd|��S|�dStt|��j �d����)a� Get an iterator given an integer, slice or container. Parameters ---------- skiprows : int, slice, container The iterator to use to skip rows; can also be a slice. Raises ------ TypeError * If `skiprows` is not a slice, integer, or Container Returns ------- it : iterable A proper iterator to use to skip rows of a DataFrame. r�r7Nz& is not a valid type for skipping rows)� isinstance�slice�start�step�list�range�stop�numbers�Integralrr� TypeError�type�__name__)r5r<r=s r2� _get_skiprowsrF\s���&�(�E�"�"���n�)��8�=�+=�A�t���E�%����5�5�6�6�6� �H�g�.� /� /��<��3I�3I���)�8�4�4�4� � ��q� �t�H�~�~�.�V�V�V� W� W�Wr4�obj�FilePath | BaseBuffer�encoding� str | None�storage_options�StorageOptions | None� str | bytesc��t|��s4t|d��s$t|t��rTt |��rEt |d||���5}|j���}ddd��n #1swxYwYnDt|ttf��r|}n%tdt|��j �d����|S)z� Try to read from a url, file or string. Parameters ---------- obj : str, unicode, path object, or file-like object Returns ------- raw_text : str �read�r)rIrKNzCannot read object of type '�') r�hasattrr:r+rr�handlerO�bytesrCrDrE)rGrIrK�handles�texts r2�_readrWys��$ �s� � � N� �3�� � � N� �s�C� � � N�&1��%5�%5� N� � ��x�� � � � )� ��>�&�&�(�(�D� )� )� )� )� )� )� )� )� )� )� )���� )� )� )� )�� �C�#�u�� &� &�N�����L�t�C�y�y�7I�L�L�L�M�M�M� �Ks�A=�=B�Bc�z�eZdZdZ d&d'd�Zd�Zd�Zd(d�Zd�Zd�Z d�Z d�Z d�Z d�Z d)d�Zd�Zd �Zd*d#�Zd+d%�ZdS),�_HtmlFrameParseraZ Base class for parsers that parse HTML into DataFrames. Parameters ---------- io : str or file-like This can be either a string of raw HTML, a valid URL using the HTTP, FTP, or FILE protocols or a file-like object. match : str or regex The text to match in the document. attrs : dict List of HTML <table> element attributes to match. encoding : str Encoding to be used by parser displayed_only : bool Whether or not items with "display:none" should be ignored extract_links : {None, "all", "header", "body", "footer"} Table elements in the specified section(s) with <a> tags will have their href extracted. .. versionadded:: 1.5.0 Attributes ---------- io : str or file-like raw HTML, URL, or file-like object match : regex The text to match in the raw HTML attrs : dict-like A dictionary of valid table attributes to use to search for table elements. encoding : str Encoding to be used by parser displayed_only : bool Whether or not items with "display:none" should be ignored extract_links : {None, "all", "header", "body", "footer"} Table elements in the specified section(s) with <a> tags will have their href extracted. .. versionadded:: 1.5.0 Notes ----- To subclass this class effectively you must override the following methods: * :func:`_build_doc` * :func:`_attr_getter` * :func:`_href_getter` * :func:`_text_getter` * :func:`_parse_td` * :func:`_parse_thead_tr` * :func:`_parse_tbody_tr` * :func:`_parse_tfoot_tr` * :func:`_parse_tables` * :func:`_equals_tag` See each method's respective documentation for details on their functionality. N�io�.FilePath | ReadBuffer[str] | ReadBuffer[bytes]�match� str | Pattern�attrs�dict[str, str] | NonerIr+�displayed_only�bool� extract_links�0Literal[None, 'header', 'footer', 'body', 'all']rKr(r-�Nonec�h�||_||_||_||_||_||_||_dS�N)rZr\r^rIr`rbrK)�selfrZr\r^rIr`rbrKs r2�__init__z_HtmlFrameParser.__init__�s>������� ��� � �� �,���*���.����r4c����������j�j��}�fd�|D��S)z� Parse and return all tables from the DOM. Returns ------- list of parsed (header, body, footer) tuples from tables. c3�B�K�|]}��|��V��dSrf)�_parse_thead_tbody_tfoot)�.0�tablergs �r2� <genexpr>z0_HtmlFrameParser.parse_tables.<locals>.<genexpr>�s1�����I�I���-�-�e�4�4�I�I�I�I�I�Ir4)� _parse_tables� _build_docr\r^)rg�tabless` r2� parse_tablesz_HtmlFrameParser.parse_tables�sD����#�#�D�O�O�$5�$5�t�z�4�:�N�N��I�I�I�I�&�I�I�I�Ir4c�,�|�|��S)aC Return the attribute value of an individual DOM node. Parameters ---------- obj : node-like A DOM node. attr : str or unicode The attribute, such as "colspan" Returns ------- str or unicode The attribute value. )�get)rgrG�attrs r2� _attr_getterz_HtmlFrameParser._attr_getter�s��$�w�w�t�}�}�r4rJc� �t|���)a Return a href if the DOM node contains a child <a> or None. Parameters ---------- obj : node-like A DOM node. Returns ------- href : str or unicode The href from the <a> child of the DOM node. �r �rgrGs r2� _href_getterz_HtmlFrameParser._href_getter���"�$�'�'�'r4c� �t|���)a Return the text of an individual DOM node. Parameters ---------- obj : node-like A DOM node. Returns ------- text : str or unicode The text from an individual DOM node. rxrys r2� _text_getterz_HtmlFrameParser._text_getter r{r4c� �t|���)a Return the td elements from a row element. Parameters ---------- obj : node-like A DOM <tr> node. Returns ------- list of node-like These are the elements of each row, i.e., the columns. rxrys r2� _parse_tdz_HtmlFrameParser._parse_td0r{r4c� �t|���)a; Return the list of thead row elements from the parsed table element. Parameters ---------- table : a table element that contains zero or more thead elements. Returns ------- list of node-like These are the <tr> row elements of a table. rx�rgrms r2�_parse_thead_trz _HtmlFrameParser._parse_thead_tr@���"�$�'�'�'r4c� �t|���)a� Return the list of tbody row elements from the parsed table element. HTML5 table bodies consist of either 0 or more <tbody> elements (which only contain <tr> elements) or 0 or more <tr> elements. This method checks for both structures. Parameters ---------- table : a table element that contains row elements. Returns ------- list of node-like These are the <tr> row elements of a table. rxr�s r2�_parse_tbody_trz _HtmlFrameParser._parse_tbody_trO���""�$�'�'�'r4c� �t|���)a, Return the list of tfoot row elements from the parsed table element. Parameters ---------- table : a table element that contains row elements. Returns ------- list of node-like These are the <tr> row elements of a table. rxr�s r2�_parse_tfoot_trz _HtmlFrameParser._parse_tfoot_trbr�r4c� �t|���)ai Return all tables from the parsed DOM. Parameters ---------- document : the DOM from which to parse the table element. match : str or regular expression The text to search for in the DOM tree. attrs : dict A dictionary of table attributes that can be used to disambiguate multiple tables on a page. Raises ------ ValueError : `match` does not match any text in the document. Returns ------- list of node-like HTML <table> elements to be parsed into raw data. rx)rg�documentr\r^s r2roz_HtmlFrameParser._parse_tablesqs��0"�$�'�'�'r4c� �t|���)a? Return whether an individual DOM node matches a tag Parameters ---------- obj : node-like A DOM node. tag : str Tag name to be checked for equality. Returns ------- boolean Whether `obj`'s tag name is `tag` rx�rgrG�tags r2� _equals_tagz_HtmlFrameParser._equals_tag�r�r4c� �t|���)z� Return a tree-like object that can be used to iterate over the DOM. Returns ------- node-like The DOM from which to parse the table element. rx)rgs r2rpz_HtmlFrameParser._build_doc�s��"�$�'�'�'r4c������|��}��|��}��|��}�fd�}|sN|rL||d��r;|�|�d����|r||d���;��|d���}��|d���}��|d���}|||fS)a  Given a table, return parsed header, body, and foot. Parameters ---------- table_html : node-like Returns ------- tuple of (header, body, footer), each a list of list-of-text rows. Notes ----- Header and body are lists-of-lists. Top level list is a list of rows. Each row is a list of str text. Logic: Use <thead>, <tbody>, <tfoot> elements to identify header, body, and footer, otherwise: - Put all rows into body - Move rows from top of body to header only if all elements inside row are <th> - Move rows from bottom of body to footer only if all elements inside row are <th> c�`��t�fd���|��D����S)Nc3�D�K�|]}��|d��V��dS)�thN)r�)rl�trgs �r2rnzS_HtmlFrameParser._parse_thead_tbody_tfoot.<locals>.row_is_all_th.<locals>.<genexpr>�s3�����N�N�Q�t�'�'��4�0�0�N�N�N�N�N�Nr4)�allr)�rowrgs �r2� row_is_all_thz@_HtmlFrameParser._parse_thead_tbody_tfoot.<locals>.row_is_all_th�s2����N�N�N�N�$�.�.��:M�:M�N�N�N�N�N� Nr4r�header)�section�body�footer)r�r�r��append�pop�_expand_colspan_rowspan) rg� table_html� header_rows� body_rows� footer_rowsr�r�r�r�s ` r2rkz)_HtmlFrameParser._parse_thead_tbody_tfoot�s���2�*�*�:�6�6� ��(�(��4�4� ��*�*�:�6�6� � O� O� O� O� O�� 5�� 5� � �i��l� ;� ;� 5��"�"�9�=�=��#3�#3�4�4�4�� 5� � �i��l� ;� ;� 5��-�-�k�8�-�L�L���+�+�I�v�+�F�F���-�-�k�8�-�L�L���t�V�#�#r4r��#Literal['header', 'footer', 'body']c �z�g}g}|D�]�}g}g}d}|�|��} | D�]\} |rz|dd|krh|�d��\} } } |�| ��| dkr|�| | | dz f��|dz }|r|dd|k�ht|�| ����}|jd|fvr|�| ��}||f}t|�| d��pd��}t|�| d��pd��}t|��D]=}|�|��|dkr|�|||dz f��|dz }�>��^|D]<\} } } |�| ��| dkr|�| | | dz f���=|�|��|}���|r\g}g}|D]<\} } } |�| ��| dkr|�| | | dz f���=|�|��|}|�\|S)a* Given a list of <tr>s, return a list of text rows. Parameters ---------- rows : list of node-like List of <tr>s section : the section that the rows belong to (header, body or footer). Returns ------- list of list Each returned row is a list of str text, or tuple (text, link) if extract_links is not None. Notes ----- Any cell with ``rowspan`` or ``colspan`` will have its contents copied to subsequent cells. rr9r��rowspan�colspan) rr�r�r3r}rbrz�intrvr?)rg�rowsr�� all_texts� remainder�tr�texts�next_remainder�index�tds�td�prev_i� prev_text� prev_rowspanrV�hrefr�r��_s r2r�z(_HtmlFrameParser._expand_colspan_rowspan�s���.� � � ��% '�% '�B��E��N��E��.�.��$�$�C�� � �� ��I�a�L��O�u�$<�$<�6?�m�m�A�6F�6F�3�F�I�|��L�L��+�+�+�#�a�'�'�&�-�-�v�y�,�QR�BR�.S�T�T�T��Q�J�E�  ��I�a�L��O�u�$<�$<�*�$�*;�*;�B�*?�*?�@�@���%�%��)9�9�9��,�,�R�0�0�D� �$�<�D��d�/�/��I�>�>�C�!�D�D���d�/�/��I�>�>�C�!�D�D���w�����A��L�L��&�&�&���{�{�&�-�-�u�d�G�a�K�.H�I�I�I��Q�J�E�E� �4=� Q� Q�/�� �<�� � �Y�'�'�'��!�#�#�"�)�)�6�9�l�Q�>N�*O�P�P�P�� � � �U� #� #� #�&�I�I�� '��N��E�3<� Q� Q�/�� �<�� � �Y�'�'�'��!�#�#�"�)�)�6�9�l�Q�>N�*O�P�P�P�� � � �U� #� #� #�&�I�� '��r4� attr_namec�2��|js|S�fd�|D��S)a� Return list of tables, potentially removing hidden elements Parameters ---------- tbl_list : list of node-like Type of list elements will vary depending upon parser used attr_name : str Name of the accessor for retrieving HTML attributes Returns ------- list of node-like Return type matches `tbl_list` c���g|]>}dt|����dd���dd��v�<|��?S)� display:none�style�r/)�getattrrt�replace)rl�xr�s �r2� <listcomp>z:_HtmlFrameParser._handle_hidden_tables.<locals>.<listcomp>;sh��� � � ����1�i�(�(�,�,�W�b�9�9�A�A�#�r�J�J�K�K� �K�K�Kr4)r`)rg�tbl_listr�s `r2�_handle_hidden_tablesz&_HtmlFrameParser._handle_hidden_tables(s@��� �"� ��O� � � � �� � � � r4rf)rZr[r\r]r^r_rIr+r`rarbrcrKr(r-rd�r-rJ�r-ra)r�r�)r�r+)rE� __module__� __qualname__�__doc__rhrrrvrzr}rr�r�r�ror�rprkr�r��r4r2rYrY�s.������B�B�X+/�/�/�/�/�/�$ J� J� J����((�(�(�(� (�(�(� (�(�(� (� (� (�(�(�(�& (� (� (�(�(�(�4(�(�(�(�& (� (� (�+$�+$�+$�ZP�P�P�P�d � � � � � r4rYc�R�eZdZdZd�Zdd�Zd�Zdd�Zd �Zd �Z d �Z d �Z d �Z d�Z dS)�!_BeautifulSoupHtml5LibFrameParsera/ HTML to DataFrame parser that uses BeautifulSoup under the hood. See Also -------- pandas.io.html._HtmlFrameParser pandas.io.html._LxmlFrameParser Notes ----- Documentation strings for this class are in the base class :class:`pandas.io.html._HtmlFrameParser`. c�h�d}|�||���}|std���g}t��}|�|d��}|D]�}|jrk|�d��D]} | ����|�t jd�����D]} | ����||vr+|�|����|� |��|� |����|s$td t|j �������|S) Nrm)r^zNo tables foundr^r�zdisplay:\s*none)r�)�stringz!No tables found matching pattern ) �find_all� ValueError�setr�r`� decompose�re�compile�findr��add�repr�pattern) rgr�r\r^� element_namerq�result� unique_tablesrm�elems r2roz/_BeautifulSoupHtml5LibFrameParser._parse_tablesRsR��� ��"�"�<�u�"�=�=��� 0��.�/�/� /������ ��+�+�F�G�<�<��� %� %�E��"� %�!�N�N�7�3�3�%�%�D��N�N�$�$�$�$�!�N�N���<N�1O�1O�N�P�P�%�%�D��N�N�$�$�$�$��M�)�)�e�j�j��j�.F�.F�.R�� � �e�$�$�$� � � �e� $� $� $� $�� X��V��e�m�AT�AT�V�V�W�W� W�� r4r-rJc�H�|�dd���}|sdn|dS)N�aT)r�r�)r�)rgrGr�s r2rzz._BeautifulSoupHtml5LibFrameParser._href_getterks*�� �H�H�S�t�H� $� $���+�t�t�!�F�)�+r4c��|jSrf)rVrys r2r}z._BeautifulSoupHtml5LibFrameParser._text_getteros ���x�r4rac��|j|kSrf)�namer�s r2r�z-_BeautifulSoupHtml5LibFrameParser._equals_tagrs���x�3��r4c�0�|�dd���S)N)r�r�F�� recursive)r��rgr�s r2rz+_BeautifulSoupHtml5LibFrameParser._parse_tdus���|�|�L�E�|�:�:�:r4c�,�|�d��S)Nzthead tr��selectr�s r2r�z1_BeautifulSoupHtml5LibFrameParser._parse_thead_trx����|�|�J�'�'�'r4c�d�|�d��}|�dd���}||zS)Nztbody trr�Fr�)r�r��rgrm� from_tbody� from_roots r2r�z1_BeautifulSoupHtml5LibFrameParser._parse_tbody_tr{s3���\�\�*�-�-� ��N�N�4�5�N�9�9� ��I�%�%r4c�,�|�d��S)Nztfoot trr�r�s r2r�z1_BeautifulSoupHtml5LibFrameParser._parse_tfoot_tr�r�r4c�x�t|j|j|j��}|st d|j�����|S)NzNo text parsed from document: )rWrZrIrKr�)rg�raw_texts r2�_setup_build_docz2_BeautifulSoupHtml5LibFrameParser._setup_build_doc�sA�����$�-��1E�F�F��� I��G�d�g�G�G�H�H� H��r4c�D�ddlm}|���}t|t��r$|j�|�|j��}d}n |}|j}||d|���}|�d��D]}|�d|j z��� |S)Nr)� BeautifulSoup�html5lib)�features� from_encoding�br� ) �bs4r�r�r:rTrI�decoder�� replace_withrV)rgr��bdoc�udocr��soupr�s r2rpz,_BeautifulSoupHtml5LibFrameParser._build_doc�s���%�%�%�%�%�%��$�$�&�&�� �d�E� "� "� *�t�}�'@��;�;�t�}�-�-�D� �M�M��D� �M�M��}�T�J�m�T�T�T���-�-��%�%� ,� ,�B� �O�O�D�2�7�N� +� +� +� +�� r4Nr�r�)rEr�r�r�rorzr}r�rr�r�r�r�rpr�r4r2r�r�Cs������� � ����2,�,�,�,��������;�;�;�(�(�(�&�&�&� (�(�(���� ����r4r�c��d|vr|�d��|d<d�d�|���D����}d|�d�S)ar Build an xpath expression to simulate bs4's ability to pass in kwargs to search for attributes when using the lxml parser. Parameters ---------- attrs : dict A dict of HTML attributes. These are NOT checked for validity. Returns ------- expr : unicode An XPath expression that checks for the given HTML attributes. �class_�classz and c�>�g|]\}}d|�dt|������S)�@�=)r�)rl�k�vs r2r�z%_build_xpath_expr.<locals>.<listcomp>�s3��B�B�B�D�A�q�'�!�'�'�d�1�g�g�'�'�B�B�Br4�[�])r��join�items)r^r*s r2�_build_xpath_exprr�sY�� �5������8�,�,��g��� � �B�B�E�K�K�M�M�B�B�B�C�C�A� �q�8�8�8�Or4r�z$http://exslt.org/regular-expressionsc�L�eZdZdZdd�Zd�Zd�Zd�Zdd �Zd �Z d �Z d �Z d �Z dS)�_LxmlFrameParseraY HTML to DataFrame parser that uses lxml under the hood. Warning ------- This parser can only handle HTTP, FTP, and FILE urls. See Also -------- _HtmlFrameParser _BeautifulSoupLxmlFrameParser Notes ----- Documentation strings for this class are in the base class :class:`_HtmlFrameParser`. r-rJc�D�|�d��}|sdn|dS)Nz .//a/@hrefr��xpath)rgrGr�s r2rzz_LxmlFrameParser._href_getter�s&���y�y��&�&���,�t�t�T�!�W�,r4c�*�|���Srf)� text_contentrys r2r}z_LxmlFrameParser._text_getter�s�����!�!�!r4c�,�|�d��S)N� ./td|./thr r�s r2rz_LxmlFrameParser._parse_td�s���y�y��%�%�%r4c�2�|j}dt|���d�}|r|t|��z }|�|t���}|�|d��}|jr�|D]�}|�d��D]}|����|�d��D]G}d|j� dd ��� d d ��vr|����H��|std t|�������|S) Nz//table[.//text()[re:test(., z)]])� namespaces�attribz.//stylez .//*[@style]r�r�r�r/zNo tables found matching regex ) r�r�rr � _re_namespacer�r`� drop_treerrtr�r�) rgr�r\�kwargsr�� xpath_exprrqrmr�s r2roz_LxmlFrameParser._parse_tables�s=���-��H�T�'�]�]�G�G�G� � � 4� �+�F�3�3� 3�J���� �}��E�E���+�+�F�H�=�=�� � � )�� )� )��"�K�K� �3�3�%�%�D��N�N�$�$�$�$�!�K�K��7�7�)�)�D�%������"�)E�)E�)M�)M�c�SU�)V�)V�V�V����(�(�(��)�� P��N�t�G�}�}�N�N�O�O� O�� r4rac��|j|kSrf)r�r�s r2r�z_LxmlFrameParser._equals_tag�s���w�#�~�r4c���ddlm}ddlm}m}m}|d|j���} t|j��rGt|jd|j ���5}||j |���}d d d ��n #1swxYwYn||j|���} |� ��}n#t$rYnwxYwt|d ��s|d ddd���nl#tt f$rX}t|j��s8||j|���} |� ��}n#t$rYnwxYw|�Yd }~nd }~wwxYw|�d ��D]} d | jpdz| _�|S)a� Raises ------ ValueError * If a URL that lxml cannot parse is passed. Exception * Any other ``Exception`` thrown. For example, trying to parse a URL that is syntactically correct on a machine with no internet connection will fail. See Also -------- pandas.io.html._HtmlFrameParser._build_doc r)�XMLSyntaxError)� HTMLParser� fromstring�parseT)�recoverrIrP�rK)�parserNrzno text parsed from documentz*//brr�r�)� lxml.etreer� lxml.htmlrrrrIrrZrrKrS�getroot�AttributeErrorrR�UnicodeDecodeError�OSErrorr �tail) rgrrrrr!�frP�er�s r2rpz_LxmlFrameParser._build_doc�sA�� .�-�-�-�-�-� � � � � � � � � � � ��D�4�=�A�A�A�� N��d�g��� 2���G�S�$�2F����7����a�h�v�6�6�6�A�7�7�7�7�7�7�7�7�7�7�7����7�7�7�7�� �E�$�'�&�1�1�1�� ��I�I�K�K����!� � � ��� �����1�n�-�-� N�$�n�%C�Q��1�M�M�M� N��#�G�,� � � ��$�'�?�?� ��J�t�w�v�6�6�6���� � � � �A�A��%�����D���������������� �����'�'�'�"�"� -� -�B��b�g�m��,�B�G�G��s��0C�A3�' C�3A7�7C�:A7�;C�B'�&C�' B4�1C�3B4�4C�D?�'&D:�D#�"D:�# D0�-D:�/D0�0D:�:D?c���g}|�d��D]V}|�|�d����|�d��}|r|�|���W|S)Nz.//thead�./trr)r �extendr�)rgrmr��thead�elements_at_roots r2r�z _LxmlFrameParser._parse_thead_tr0st�����[�[��,�,� #� #�E� �K�K�� � �F�+�+� ,� ,� ,� %�{�{�;�7�7� �� #�� � �E�"�"�"��� r4c�`�|�d��}|�d��}||zS)Nz .//tbody//trr,r r�s r2r�z _LxmlFrameParser._parse_tbody_trBs/���[�[��0�0� ��K�K��'�'� ��I�%�%r4c�,�|�d��S)Nz .//tfoot//trr r�s r2r�z _LxmlFrameParser._parse_tfoot_trHs���{�{�>�*�*�*r4Nr�r�) rEr�r�r�rzr}rror�rpr�r�r�r�r4r2r r �s���������$-�-�-�-�"�"�"�&�&�&� ���:����8�8�8�t���$&�&�&� +�+�+�+�+r4r rdc���d�|D��}t|��}|���}|||k}dg}|���D]\}}||xx|||z zz cc<�dS)Nc�,�g|]}t|����Sr�)�len)rlr�s r2r�z$_expand_elements.<locals>.<listcomp>Ms�� '� '� '�$�C��I�I� '� '� 'r4r�)r�maxr)r��data�lens�lens_max�not_max�empty�ind�lengths r2�_expand_elementsr=Ls��� '� '�$� '� '� '�D� �$�<�<�D��x�x�z�z�H��4�8�#�$�G� �D�E��}�}���1�1� ��V� �S� � � �U�h��/�0�0� � � � �1�1r4c ��|�d��\}}}|�d��}t|d��|d<|r6||z}|�/t|��dkrd}nd�t|��D��}|r||z }t |��t |fd|i|��5}|���cddd��S#1swxYwYdS)Nr6r�r5r9rc�J�g|] \}}td�|D�����|��!S)c3�K�|]}|V��dSrfr�)rlrVs r2rnz,_data_to_frame.<locals>.<listcomp>.<genexpr>ds"����@V�@V�$��@V�@V�@V�@V�@V�@Vr4)�any)rl�ir�s r2r�z"_data_to_frame.<locals>.<listcomp>ds9��W�W�W���3�S�@V�@V�RU�@V�@V�@V�=V�=V�W�!�W�W�Wr4)r�rFr4� enumerater=r rO)r�headr��footr��tps r2�_data_to_framerGWs5���z�z�&�)�)��D�$�� �Z�Z�� !� !�F�&�v�j�'9�:�:�F�:�� � X��d�{�� �>��4�y�y�A�~�~����X�W�)�D�/�/�W�W�W�� �� �� ���T���� �D� 2� 2�� 2�6� 2� 2��b��w�w�y�y���������������������s�$C�C � C )�lxmlNr�r��flavor�HTMLFlavors | None�type[_HtmlFrameParser]c��tt�����}||vr!tt |���d|�����|dvrt d��t d��nt d��t|S)a� Choose the parser based on the input flavor. Parameters ---------- flavor : {{"lxml", "html5lib", "bs4"}} or None The type of parser to use. This must be a valid backend. Returns ------- cls : _HtmlFrameParser subclass The parser class based on the requested input flavor. Raises ------ ValueError * If `flavor` is not a valid backend. ImportError * If you do not have the requested `flavor` z* is not a valid flavor, valid flavors are )r�r�r�r�z lxml.etree)r>�_valid_parsers�keysr�r�r )rI� valid_parserss r2�_parser_dispatchrPws���*��,�,�.�.�/�/�M� �]�"�"���F�|�|� V� V�}� V� V� � � ��$�$�$�"�:�.�.�.�"�5�)�)�)�)�"�<�0�0�0� �&� !�!r4c�L�d�d�|D����}d|�d�S)Nz, c�,�g|]}t|����Sr�r)rl�els r2r�z!_print_as_set.<locals>.<listcomp>�s ��2�2�2�"�\�"�%�%�2�2�2r4�{�})r)r*�args r2� _print_as_setrW�s0�� �)�)�2�2��2�2�2� 3� 3�C� ��<�<�<�r4c�f�|�d}n�t|t��r|f}n�t|tj��rLt d�|D����s2t dt t|��j���d����nGt|t��rt |��nt|��}|dz }t|���t|��}tt��}t|��}||zs.tt|���dt|�������|S)N)rHr�c3�@K�|]}t|t��V��dSrf)r:r+)rl�flavs r2rnz#_validate_flavor.<locals>.<genexpr>�s,����<�<�T�:�d�C�(�(�<�<�<�<�<�<r4zObject of type z is not an iterable of stringsz is not a valid flavorz2 is not a valid set of flavors, valid flavors are )r:r+rr!r�rCr�rDrEr��tupler�rMrW)rI�msg� valid_flavors� flavor_sets r2�_validate_flavorr_�sJ�� �~���� �F�C� � � ����� �F�C�L� )� )� ��<�<�V�<�<�<�<�<� ��1�$�t�F�|�|�'<�"=�"=�1�1�1��� � � )���5�5�F�d�6�l�l�l�3�v�;�;�� �'�'����o�o�� �6�]�]�F���'�'�M��V���J� � � %� ���Z�(�(� :� :�(��7�7� :� :� � � � �Mr4c ���t|��}tj|��} d} |D]�} t| ��} | || |||||��} | ���}n�#t $r~}t |d��r*|���r|�d��n8t |d��r(|���st d| �d���|�|} Yd}~��d}~wwxYw| �J�| �g}|D]y} td d|i|��}|dvr?t|j t��r%td�|j D��d� ��|_ |�|���j#t$rY�vwxYw|S) N�seekablerz The flavor z� failed to parse your input. Since you passed a non-rewindable file object, we can't rewind it to try another parser. Try read_html() with a different flavor.r6)r�r�c3�dK�|]+}|dt|d��rdn|dfV��,dS)rr9Nr)rl�cols r2rnz_parse.<locals>.<genexpr>�sB����V�V�C�c�!�f�d�3�q�6�l�l�>�d�d��A��?�V�V�V�V�V�Vr4F)� tupleize_colsr�)r_r�r�rPrrr�rRra�seekrGr:�columnsrrr�r )rIrZr\r^rIr`rbrKr�compiled_match�retainedrZr!�prq�caught�retrm�dfs r2�_parserm�s���f� %� %�F��Z��&�&�N��H��!�!��!�$�'�'�� �F� � � � � � � � � �� ��^�^�%�%�F�" �E��!� � � ��r�:�&�&� �2�;�;�=�=� ����� � � � ���Z�(�(� ������ � �O�$�O�O�O��� � ��H�H�H�H�H�H����� ����$�#�#�#��� �C����� ��5�5�U�5�f�5�5�B�� 1�1�1�j�� �J�7�7�1�#�V�V�2�:�V�V�V�"'����� � �J�J�r�N�N�N�N��� � � � �H� ���� �Js,� A!�! C)�+A4C$�$C)�9A&E � E-�,E-r z.+F�,�.T)r\rIr�� index_colr5r^� parse_dates� thousandsrI�decimal� converters� na_values�keep_default_nar`rb� dtype_backendrKrZ�FilePath | ReadBuffer[str]r\r]�*HTMLFlavors | Sequence[HTMLFlavors] | Noner��int | Sequence[int] | Nonerpr^r_rqrarrrsrt� dict | Noneru�Iterable[object] | Nonervr`rbrcrw�DtypeBackend | lib.NoDefaultr(�list[DataFrame]c�p�t|tj��r|dkrtd���|dvrtd|�d����t |��t |��t |��}t|t��rott|��t|��t|��t|��g��s(tjdtt!�����t#did|�d |�d |�d |�d |�d |�d|�d|�d|�d| �d| �d| �d| �d| �d|�d|�d|�d|��S)a� Read HTML tables into a ``list`` of ``DataFrame`` objects. Parameters ---------- io : str, path object, or file-like object String, path object (implementing ``os.PathLike[str]``), or file-like object implementing a string ``read()`` function. The string can represent a URL or the HTML itself. Note that lxml only accepts the http, ftp and file url protocols. If you have a URL that starts with ``'https'`` you might try removing the ``'s'``. .. deprecated:: 2.1.0 Passing html literal strings is deprecated. Wrap literal string/bytes input in ``io.StringIO``/``io.BytesIO`` instead. match : str or compiled regular expression, optional The set of tables containing text matching this regex or string will be returned. Unless the HTML is extremely simple you will probably need to pass a non-empty string here. Defaults to '.+' (match any non-empty string). The default value will return all tables contained on a page. This value is converted to a regular expression so that there is consistent behavior between Beautiful Soup and lxml. flavor : {{"lxml", "html5lib", "bs4"}} or list-like, optional The parsing engine (or list of parsing engines) to use. 'bs4' and 'html5lib' are synonymous with each other, they are both there for backwards compatibility. The default of ``None`` tries to use ``lxml`` to parse and if that fails it falls back on ``bs4`` + ``html5lib``. header : int or list-like, optional The row (or list of rows for a :class:`~pandas.MultiIndex`) to use to make the columns headers. index_col : int or list-like, optional The column (or list of columns) to use to create the index. skiprows : int, list-like or slice, optional Number of rows to skip after parsing the column integer. 0-based. If a sequence of integers or a slice is given, will skip the rows indexed by that sequence. Note that a single element sequence means 'skip the nth row' whereas an integer means 'skip n rows'. attrs : dict, optional This is a dictionary of attributes that you can pass to use to identify the table in the HTML. These are not checked for validity before being passed to lxml or Beautiful Soup. However, these attributes must be valid HTML table attributes to work correctly. For example, :: attrs = {{'id': 'table'}} is a valid attribute dictionary because the 'id' HTML tag attribute is a valid HTML attribute for *any* HTML tag as per `this document <https://html.spec.whatwg.org/multipage/dom.html#global-attributes>`__. :: attrs = {{'asdf': 'table'}} is *not* a valid attribute dictionary because 'asdf' is not a valid HTML attribute even if it is a valid XML attribute. Valid HTML 4.01 table attributes can be found `here <http://www.w3.org/TR/REC-html40/struct/tables.html#h-11.2>`__. A working draft of the HTML 5 spec can be found `here <https://html.spec.whatwg.org/multipage/tables.html>`__. It contains the latest information on table attributes for the modern web. parse_dates : bool, optional See :func:`~read_csv` for more details. thousands : str, optional Separator to use to parse thousands. Defaults to ``','``. encoding : str, optional The encoding used to decode the web page. Defaults to ``None``.``None`` preserves the previous encoding behavior, which depends on the underlying parser library (e.g., the parser library will try to use the encoding provided by the document). decimal : str, default '.' Character to recognize as decimal point (e.g. use ',' for European data). converters : dict, default None Dict of functions for converting values in certain columns. Keys can either be integers or column labels, values are functions that take one input argument, the cell (not column) content, and return the transformed content. na_values : iterable, default None Custom NA values. keep_default_na : bool, default True If na_values are specified and keep_default_na is False the default NaN values are overridden, otherwise they're appended to. displayed_only : bool, default True Whether elements with "display: none" should be parsed. extract_links : {{None, "all", "header", "body", "footer"}} Table elements in the specified section(s) with <a> tags will have their href extracted. .. versionadded:: 1.5.0 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 {storage_options} .. versionadded:: 2.1.0 Returns ------- dfs A list of DataFrames. See Also -------- read_csv : Read a comma-separated values (csv) file into DataFrame. Notes ----- Before using this function you should read the :ref:`gotchas about the HTML parsing libraries <io.html.gotchas>`. Expect to do some cleanup after you call this function. For example, you might need to manually assign column names if the column names are converted to NaN when you pass the `header=0` argument. We try to assume as little as possible about the structure of the table and push the idiosyncrasies of the HTML contained in the table to the user. This function searches for ``<table>`` elements and only for ``<tr>`` and ``<th>`` rows and ``<td>`` elements within each ``<tr>`` or ``<th>`` element in the table. ``<td>`` stands for "table data". This function attempts to properly handle ``colspan`` and ``rowspan`` attributes. If the function has a ``<thead>`` argument, it is used to construct the header, otherwise the function attempts to find the header within the body (by putting rows with only ``<th>`` elements into the header). Similar to :func:`~read_csv` the `header` argument is applied **after** `skiprows` is applied. This function will *always* return a list of :class:`DataFrame` *or* it will fail, e.g., it will *not* return an empty list. Examples -------- See the :ref:`read_html documentation in the IO section of the docs <io.read_html>` for some examples of reading in HTML tables. rzPcannot skip rows starting from the end of the data (you passed a negative value))Nr�r�r�r�zO`extract_links` must be one of {None, "header", "footer", "body", "all"}, got "�"z�Passing literal html to 'read_html' is deprecated and will be removed in a future version. To read from a literal string, wrap it in a 'StringIO' object.)� stacklevelrIrZr\r�rpr5rqrrr^rIrsrtrurvr`rbrwrKr�)r:rArBr�rrrr+rArrrr�warnings�warn� FutureWarningrrm)rZr\rIr�rpr5r^rqrrrIrsrtrurvr`rbrwrKs r2� read_htmlr�s��j�(�G�,�-�-� �(�Q�,�,�� 1� � � ��E�E�E�� !�� !� !� !� � � � ������ �&�&�&� �� � �B��"�c��� �3� �� � � ��O�O� �2�J�J� �"� � �  �$�$� � � � >� �'�)�)�  � � � � � � � ��v� � �2� ��e� ��v�  � �)�  � ��  � �K� ��)� ��e� ��� ��� ��:� ��)� �(�� �&�~� � $�m�! �"$�m�# �$(��% �r4)r*r+r,rr-r+)r5r6r-r7)rGrHrIrJrKrLr-rM)r-r+)r-rd)rIrJr-rK)&rZrxr\r]rIryr�rzrprzr5r6r^r_rqrarrrJrIrJrsr+rtr{rur|rvrar`rarbrcrwr}rKr(r-r~)Pr�� __future__r� collectionsrrAr�r�typingrrrr�� pandas._libsr �pandas.compat._optionalr � pandas.errorsr r �pandas.util._decoratorsr �pandas.util._exceptionsr�pandas.util._validatorsr�pandas.core.dtypes.commonr�pandasr�pandas.core.indexes.baser�pandas.core.indexes.multir�pandas.core.seriesr�pandas.core.shared_docsr�pandas.io.commonrrrrrrr�pandas.io.formats.printingr�pandas.io.parsersr �collections.abcr!r"�pandas._typingr#r$r%r&r'r(r)r��_RE_WHITESPACEr3rFrWrYr�rrr r=rGrMrPrWr_rm� no_defaultr�r�r4r2�<module>r�s����� #�"�"�"�"�"����������� � � � ����������������� ����������>�>�>�>�>�>���������(�'�'�'�'�'�4�4�4�4�4�4�7�7�7�7�7�7�2�2�2�2�2�2�������*�*�*�*�*�*�0�0�0�0�0�0�%�%�%�%�%�%�0�0�0�0�0�0�������������������4�3�3�3�3�3�(�(�(�(�(�(��!��������� ����������������!� � � � � � ���-�.�.��1?�%�%�%�%�%�&X�X�X�X�:����Bf �f �f �f �f �f �f �f �R W�W�W�W�W�(8�W�W�W�t����.�=�>� �R+�R+�R+�R+�R+�'�R+�R+�R+�j1�1�1�1����2 � �1� ,� ��� "� "� "� "�F���� ���8D�D�D�N��\�"3�4�5�5�5� �9=�)-�,0�37�#'�����"�)-� ��FJ�25�.�&*�'h�h�h�h�h�6�5�h�h�hr4
Memory