zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
U
¬ý°d¶›ã@sndZddlmZddlmZddlZddlZddlmZm    Z    m
Z
m Z m Z m Z ddlmZddlmZmZmZmZddlmZdd    lmZmZdd
lmZdd lmZdd lmZdd l m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,ddl-m.Z.ddl/m0Z0erddlm1Z1da2da3da4da5ddœdd„Z6e 7d¡Z8e8fddddœdd„Z9dd d!œd"d#„Z:d$d%d&d'œd(d)„Z;Gd*d+„d+ƒZ<Gd,d-„d-e<ƒZ=ddœd.d/„Z>d0d1iZ?Gd2d3„d3e<ƒZ@ddœd4d5„ZAd6d7„ZBe@e@e=e=d8œZCd%d9d:œd;d<„ZDddœd=d>„ZEd?d@„ZFdAdB„ZGdCdddddddDddEdddFdFdejHdGœdHdId%dJdJddKdLd%d%ddMdNdLdLdOdPdQdRœdSdT„ZIdS)UzW
:mod:`pandas.io.html` is a module containing functionality for dealing with
HTML IO.
 
é)Ú annotations)ÚabcN)Ú TYPE_CHECKINGÚIterableÚLiteralÚPatternÚSequenceÚcast)Úlib)Ú
BaseBufferÚ DtypeBackendÚFilePathÚ
ReadBuffer)Úimport_optional_dependency)ÚAbstractMethodErrorÚEmptyDataError)Úcheck_dtype_backend)Ú is_list_like©Úisna)ÚIndex)Ú
MultiIndex)ÚSeries)Ú file_existsÚ
get_handleÚis_urlÚstringify_pathÚurlopenÚvalidate_header_arg©Ú pprint_thing)Ú
TextParser)Ú    DataFrameFÚNone©ÚreturncCsLtrdStddd}|dk    atddd}|dk    atddd}|dk    adadS)NÚbs4Úignore)Úerrorsz
lxml.etreeÚhtml5libT)Ú_IMPORTSrÚ_HAS_BS4Ú    _HAS_LXMLÚ _HAS_HTML5LIB)r&Úlxmlr)©r/úEd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/io/html.pyÚ
_importers>s   r1z[\r\n]+|\s{2,}Ústrr)ÚsÚregexr%cCs| 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)r3r4r/r/r0Ú_remove_whitespaceYsr8z"int | Sequence[int] | slice | Noneúint | Sequence[int])Úskiprowsr%cCstt|tƒr2|jpd|jpd}}tt||j|ƒƒSt|tjƒsFt    |ƒrPt
d|ƒS|dkr\dSt t |ƒj ›dƒ‚dS)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ér9Nz& is not a valid type for skipping rows)Ú
isinstanceÚsliceÚstartÚstepÚlistÚrangeÚstopÚnumbersÚIntegralrr    Ú    TypeErrorÚtypeÚ__name__)r:r>r?r/r/r0Ú _get_skiprowsls
 
rHzFilePath | BaseBufferú
str | Nonez str | bytes)ÚobjÚencodingr%c    Csxt|ƒs$t|dƒs$t|tƒrJt|ƒrJt|d|d}|j ¡}W5QRXn*t|ttfƒr^|}nt    dt
|ƒ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)rKzCannot read object of type 'ú') rÚhasattrr<r2rrÚhandlerLÚbytesrErFrG)rJrKZhandlesÚtextr/r/r0Ú_read‰sÿþýýrSc@s eZdZdZdddddddd    œd
d „Zd d „Zdd„Zdd„Zdd„Zdd„Z    dd„Z
dd„Z dd„Z dd„Z dd„Zd d!„Zd"d#„Zd$d%œd&d'„Zd(d)„Zd*S)+Ú_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.
    z.FilePath | ReadBuffer[str] | ReadBuffer[bytes]ú str | Patternúdict[str, str] | Noner2Úboolú2Literal[(None, 'header', 'footer', 'body', 'all')]r#)ÚioÚmatchÚattrsrKÚdisplayed_onlyÚ extract_linksr%cCs(||_||_||_||_||_||_dS©N)rYrZr[rKr\r])ÚselfrYrZr[rKr\r]r/r/r0Ú__init__és     z_HtmlFrameParser.__init__cs(ˆ ˆ ¡ˆjˆj¡}‡fdd„|DƒS)zž
        Parse and return all tables from the DOM.
 
        Returns
        -------
        list of parsed (header, body, footer) tuples from tables.
        c3s|]}ˆ |¡VqdSr^)Ú_parse_thead_tbody_tfoot)Ú.0Útable©r_r/r0Ú    <genexpr>sz0_HtmlFrameParser.parse_tables.<locals>.<genexpr>)Ú _parse_tablesÚ
_build_docrZr[)r_Útablesr/rdr0Ú parse_tablesùsz_HtmlFrameParser.parse_tablescCs
| |¡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)r_rJÚattrr/r/r0Ú _attr_gettersz_HtmlFrameParser._attr_gettercCs t|ƒ‚dS)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.
        N©r©r_rJr/r/r0Ú _href_gettersz_HtmlFrameParser._href_gettercCs t|ƒ‚dS)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.
        Nrmrnr/r/r0Ú _text_getter(sz_HtmlFrameParser._text_gettercCs t|ƒ‚dS)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.
        Nrmrnr/r/r0Ú    _parse_td8sz_HtmlFrameParser._parse_tdcCs t|ƒ‚dS)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.
        Nrm©r_rcr/r/r0Ú_parse_thead_trHs z _HtmlFrameParser._parse_thead_trcCs t|ƒ‚dS)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.
        Nrmrrr/r/r0Ú_parse_tbody_trWsz _HtmlFrameParser._parse_tbody_trcCs t|ƒ‚dS)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.
        Nrmrrr/r/r0Ú_parse_tfoot_trjs z _HtmlFrameParser._parse_tfoot_trcCs t|ƒ‚dS)ad
        Return all tables from the parsed DOM.
 
        Parameters
        ----------
        doc : 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.
        Nrm)r_ÚdocrZr[r/r/r0rfysz_HtmlFrameParser._parse_tablescCs t|ƒ‚dS)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`
        Nrm©r_rJÚtagr/r/r0Ú _equals_tag“sz_HtmlFrameParser._equals_tagcCs t|ƒ‚dS)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.
        Nrmrdr/r/r0rg¦s    z_HtmlFrameParser._build_docc    s„ˆ |¡}ˆ |¡}ˆ |¡}‡fdd„}|sP|rP||dƒrP| | d¡¡q.ˆj|dd}ˆj|dd}ˆj|dd}|||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>
        cst‡fdd„ˆ |¡DƒƒS)Nc3s|]}ˆ |d¡VqdS)ÚthN)ry)rbÚtrdr/r0reÏszS_HtmlFrameParser._parse_thead_tbody_tfoot.<locals>.row_is_all_th.<locals>.<genexpr>)Úallrq)Úrowrdr/r0Ú row_is_all_thÎsz@_HtmlFrameParser._parse_thead_tbody_tfoot.<locals>.row_is_all_thrÚheader©ÚsectionÚbodyÚfooter)rsrtruÚappendÚpopÚ_expand_colspan_rowspan)    r_Z
table_htmlZ header_rowsZ    body_rowsZ footer_rowsr~rr‚rƒr/rdr0ra±s
 
 
 z)_HtmlFrameParser._parse_thead_tbody_tfootz%Literal[('header', 'footer', 'body')]r€c    CsÂg}g}|D]T}g}g}d}| |¡}    |    D]ì}
|r„|dd|kr„| d¡\} } } | | ¡| dkrz| | | | df¡|d7}q0t| |
¡ƒ}|jd|fkr²| |
¡}||f}t| |
d¡pÂdƒ}t| |
d¡pÖdƒ}t    |ƒD]4}| |¡|dkr| |||df¡|d7}qâq,|D]4\} } } | | ¡| dkr| | | | df¡q| |¡|}q |r¾g}g}|D]4\} } } | | ¡| dkrv| | | | df¡qv| |¡|}qd|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.
        rr;r|ÚrowspanÚcolspan)
rqr…r„r8rpr]roÚintrlrA)r_ÚrowsrZ    all_textsÚ    remainderÚtrZtextsZnext_remainderÚindexZtdsÚtdZprev_iZ    prev_textZ prev_rowspanrRÚhrefr‡rˆÚ_r/r/r0r†ÞsTþ
 
 
 
 
 
 
 
 
 
 
 
 
z(_HtmlFrameParser._expand_colspan_rowspancs|js
|S‡fdd„|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`
        cs.g|]&}dt|ˆƒ dd¡ dd¡kr|‘qS)ú display:noneÚstyleÚr5)ÚgetattrrjÚreplace)rbÚx©Ú    attr_namer/r0Ú
<listcomp>Cs
ÿþz:_HtmlFrameParser._handle_hidden_tables.<locals>.<listcomp>)r\)r_Ztbl_listr˜r/r—r0Ú_handle_hidden_tables0s
 
þz&_HtmlFrameParser._handle_hidden_tablesN)rGÚ
__module__Ú __qualname__Ú__doc__r`rirlrorprqrsrtrurfryrgrar†ršr/r/r/r0rT¤s D  -RrTcs|eZdZdZddœ‡fdd„ Zdd„Zddœd    d
„Zd d „Zd d„Zdd„Z    dd„Z
dd„Z dd„Z dd„Z dd„Z‡ZS)Ú!_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`.
    r#r$cs(tƒj||Žddlm}|dƒ|_dS)Nr)Ú SoupStrainerrc)Úsuperr`r&rŸÚ    _strainer)r_ÚargsÚkwargsrŸ©Ú    __class__r/r0r`Zs z*_BeautifulSoupHtml5LibFrameParser.__init__c
Cs°|jj}|j||d}|s"tdƒ‚g}tƒ}| |d¡}|D]V}|jrf|jt d¡dD] }    |         ¡qX||krˆ|j
|ddk    rˆ|  |¡|  |¡q<|s¬tdt |jƒ›ƒ‚|S)N)r[zNo tables foundr[zdisplay:\s*none)r’)Ústringz!No tables found matching pattern )r¡ÚnameÚfind_allÚ
ValueErrorÚsetršr\ÚreÚcompileZ    decomposeÚfindr„ÚaddÚreprÚpattern)
r_rvrZr[Z element_namerhÚresultZ unique_tablesrcÚelemr/r/r0rf`s" 
 
 z/_BeautifulSoupHtml5LibFrameParser._parse_tablesrIcCs|jddd}|sdS|dS)NÚaT)rr)r­)r_rJr³r/r/r0roxsz._BeautifulSoupHtml5LibFrameParser._href_gettercCs|jSr^)rRrnr/r/r0rp|sz._BeautifulSoupHtml5LibFrameParser._text_gettercCs
|j|kSr^)r§rwr/r/r0rysz-_BeautifulSoupHtml5LibFrameParser._equals_tagcCs|jdddS)N)rŽrzF©Ú    recursive)r¨©r_r}r/r/r0rq‚sz+_BeautifulSoupHtml5LibFrameParser._parse_tdcCs
| d¡S)Nzthead tr©Úselectrrr/r/r0rs…sz1_BeautifulSoupHtml5LibFrameParser._parse_thead_trcCs | d¡}|jddd}||S)Nztbody trrŒFr´)r¸r¨©r_rcZ
from_tbodyZ    from_rootr/r/r0rtˆs
z1_BeautifulSoupHtml5LibFrameParser._parse_tbody_trcCs
| d¡S)Nztfoot trr·rrr/r/r0ruŽsz1_BeautifulSoupHtml5LibFrameParser._parse_tfoot_trcCs&t|j|jƒ}|s"td|j›ƒ‚|S)NzNo text parsed from document: )rSrYrKr©)r_Zraw_textr/r/r0Ú_setup_build_doc‘sz2_BeautifulSoupHtml5LibFrameParser._setup_build_doccCsvddlm}| ¡}t|tƒr:|jdk    r:| |j¡}d}n
|}|j}||d|d}| d¡D]}| d|j    ¡q\|S)Nr)Ú BeautifulSoupr))ÚfeaturesÚ from_encodingÚbrÚ
)
r&r»rºr<rQrKÚdecoder¨Z replace_withrR)r_r»ZbdocZudocr½Zsoupr¾r/r/r0rg—s  z,_BeautifulSoupHtml5LibFrameParser._build_doc)rGr›rœrr`rfrorpryrqrsrtrurºrgÚ __classcell__r/r/r¤r0ržKsržcCs:d|kr| d¡|d<d dd„| ¡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 cSs$g|]\}}d|›dt|ƒ›‘qS)ú@ú=)r¯)rbÚkÚvr/r/r0r™½sz%_build_xpath_expr.<locals>.<listcomp>ú[ú])r…ÚjoinÚitems)r[r3r/r/r0Ú_build_xpath_exprªsrÌr«z$http://exslt.org/regular-expressionsc@s^eZdZdZddœdd„Zdd„Zdd    „Zd
d „Zd d „Zdd„Z    dd„Z
dd„Z dd„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`.
    rIr$cCs| d¡}|sdS|dS)Nz
.//a/@hrefr©Úxpath)r_rJrr/r/r0ro×s
z_LxmlFrameParser._href_gettercCs| ¡Sr^)Ú text_contentrnr/r/r0rpÛsz_LxmlFrameParser._text_gettercCs
| d¡S)Nú    ./td|./thrÎr¶r/r/r0rqÞsz_LxmlFrameParser._parse_tdc    Cs¢|j}dt|ƒ›d}|r&|t|ƒ7}|j|td}| |d¡}|jrˆ|D]<}| d¡D],}d|j dd¡     d    d¡krX| 
¡  |¡qXqJ|sžt d
t|ƒ›ƒ‚|S) Nz//table[.//text()[re:test(., z)]])Ú
namespacesÚattribz .//*[@style]r‘r’r“r5zNo tables found matching regex ) r°r¯rÌrÏÚ _re_namespaceršr\rÓrjr•Z    getparentÚremover©)    r_rvrZr£r°Z
xpath_exprrhrcr²r/r/r0rfãs  z_LxmlFrameParser._parse_tablescCs
|j|kSr^)rxrwr/r/r0ryÿsz_LxmlFrameParser._equals_tagc
Cs:ddlm}ddlm}m}m}|d|jd}zbt|jƒr^t    |jƒ}|||d}W5QRXn||j|d}z | 
¡}Wnt k
rŒYnXWnft t fk
rö}zDt|jƒsâ||j|d}z | 
¡}Wqæt k
rÞYqæXn|‚W5d}~XYnXt|dƒs|d    dddƒ‚| d
¡D]}    d |    jp,d |    _q|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)ZrecoverrK)ÚparserNrÐzno text parsed from documentz*//brr¿r“)Z
lxml.etreerÖZ    lxml.htmlr×rØrÙrKrrYrÚgetrootÚAttributeErrorÚUnicodeDecodeErrorÚOSErrorrOrÏÚtail)
r_rÖr×rØrÙrÚÚfrMÚer¾r/r/r0rgs2 
 
 
  z_LxmlFrameParser._build_doccCs@g}| d¡D],}| | d¡¡| d¡}|r| |¡q|S)Nz.//theadú./trrÑ)rÏÚextendr„)r_rcrŠÚtheadZelements_at_rootr/r/r0rs:s
 z _LxmlFrameParser._parse_thead_trcCs| d¡}| d¡}||S)Nz .//tbody//trrârÎr¹r/r/r0rtLs
 
z _LxmlFrameParser._parse_tbody_trcCs
| d¡S)Nz .//tfoot//trrÎrrr/r/r0ruRsz _LxmlFrameParser._parse_tfoot_trN) rGr›rœrrorprqrfryrgrsrtrur/r/r/r0rÍÄs8rÍcCs^dd„|Dƒ}t|ƒ}| ¡}|||k}dg}| ¡D] \}}|||||7<q8dS)NcSsg|] }t|ƒ‘qSr/)Úlen)rbr²r/r/r0r™Wsz$_expand_elements.<locals>.<listcomp>r“)rÚmaxrË)r‚ÚdataZlensZlens_maxZnot_maxÚemptyÚindÚlengthr/r/r0Ú_expand_elementsVs rëc
Ksª| d¡\}}}| d¡}t|dƒ|d<|rb||}|dkrbt|ƒdkrPd}ndd„t|ƒDƒ}|rn||7}t|ƒt|fd|i|—Ž}| ¡W5QR£SQRXdS)Nrçrr:r;rcSs&g|]\}}tdd„|Dƒƒr|‘qS)css|]
}|VqdSr^r/)rbrRr/r/r0rensz,_data_to_frame.<locals>.<listcomp>.<genexpr>)Úany)rbÚir}r/r/r0r™nsz"_data_to_frame.<locals>.<listcomp>)r…rHråÚ    enumeraterër!rL)r£Úheadr‚ZfootrÚtpr/r/r0Ú_data_to_frameas
 rñ)r.Nr)r&ztype[_HtmlFrameParser])Úflavorr%cCshtt ¡ƒ}||kr*tt|ƒ›d|›ƒ‚|dkrTts>tdƒ‚tsJtdƒ‚tdƒ}n t    s`tdƒ‚t|S)aº
    Choose the parser based on the input flavor.
 
    Parameters
    ----------
    flavor : str
        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)z%html5lib not found, please install itz1BeautifulSoup4 (bs4) not found, please install itr&z!lxml not found, please install it)
r@Ú_valid_parsersÚkeysr©r¯r-Ú ImportErrorr+rr,)ròZ valid_parsersr&r/r/r0Ú_parser_dispatchs ÿ
röcCs d dd„|Dƒ¡}d|›dS)Nz, cSsg|] }t|ƒ‘qSr/r)rbÚelr/r/r0r™«sz!_print_as_set.<locals>.<listcomp>Ú{Ú})rÊ)r3Úargr/r/r0Ú _print_as_setªsrûcCsÂ|dkrd}nvt|tƒr |f}ndt|tjƒrZtdd„|Dƒƒs„tdtt|ƒjƒ›dƒ‚n*t|tƒrlt|ƒnt|ƒ}|d7}t    |ƒ‚t
|ƒ}t t ƒ}t |ƒ}||@s¾t    t |ƒ›dt |ƒ›ƒ‚|S)N)r.r&css|]}t|tƒVqdSr^)r<r2)rbÚflavr/r/r0reµsz#_validate_flavor.<locals>.<genexpr>zObject 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<r2rrr|rEr¯rFrGr©Útuplerªrórû)ròÚmsgZ valid_flavorsZ
flavor_setr/r/r0Ú_validate_flavor¯s(
 ÿÿrÿc KsDt|ƒ}t |¡}d}    |D]˜}
t|
ƒ} | ||||||ƒ} z |  ¡} Wnhtk
r¬}zJt|dƒrt| ¡rt| d¡n$t|dƒr˜| ¡s˜td|
›dƒ|‚|}    W5d}~XYqXqÄq|    dk    sÀt    ‚|    ‚g}| D]r}zRt
fd|i|—Ž}|dkrt |j t ƒrtdd„|j Dƒd    d
|_ | |¡WqÌtk
r<YqÌYqÌXqÌ|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.rç)r|rcss.|]&}|dt|dƒrdn|dfVqdS)rr;Nr)rbÚcolr/r/r0reösz_parse.<locals>.<genexpr>F)Z tupleize_cols)rÿr«r¬rörir©rOrÚseekÚAssertionErrorrñr<Úcolumnsrrr„r)ròrYrZr[rKr\r]r£Zcompiled_matchZretainedrürÚÚprhZcaughtÚretrcZdfr/r/r0Ú_parseËsJ
 
ÿû  ÿþ rz.+ú,Ú.T)rZròrÚ    index_colr:r[Ú parse_datesÚ    thousandsrKÚdecimalÚ
convertersÚ    na_valuesÚkeep_default_nar\r]Ú dtype_backendzFilePath | ReadBuffer[str]rUzint | Sequence[int] | NonerVrWz dict | NonezIterable[object] | NonerXzDtypeBackend | lib.NoDefaultzlist[DataFrame])rYrZròrr
r:r[r r rKr rrrr\r]rr%cCs|tƒt|tjƒr"|dkr"tdƒ‚|dkr:td|›dƒ‚t|ƒt|ƒt|ƒ}t||||||||||    |
| | | |||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'``.
 
    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 : str, optional
        The parsing engine 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"}, defaults to NumPy backed DataFrames
        Which dtype_backend to use, e.g. whether a DataFrame should have NumPy
        arrays, nullable dtypes are used for all dtypes that have a nullable
        implementation when "numpy_nullable" is set, pyarrow is used for all
        dtypes if "pyarrow" is set.
 
        The dtype_backends are still experimential.
 
        .. versionadded:: 2.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))Nrrƒr‚r|zO`extract_links` must be one of {None, "header", "footer", "body", "all"}, got "ú")ròrYrZrr
r:r r r[rKr rrrr\r]r)    r1r<rCrDr©rrrr)rYrZròrr
r:r[r r rKr rrrr\r]rr/r/r0Ú    read_htmls@)ÿ
ÿïr)JrÚ
__future__rÚ collectionsrrCr«Útypingrrrrrr    Z pandas._libsr
Zpandas._typingr r r rZpandas.compat._optionalrZ pandas.errorsrrZpandas.util._validatorsrZpandas.core.dtypes.commonrZpandasrZpandas.core.indexes.baserZpandas.core.indexes.multirZpandas.core.seriesrZpandas.io.commonrrrrrrZpandas.io.formats.printingr Zpandas.io.parsersr!r"r*r+r,r-r1r¬Z_RE_WHITESPACEr8rHrSrTržrÌrÔrÍrërñrórörûrÿrZ
no_defaultrr/r/r/r0Ú<module>s„                   
*_ ü)8î