BUG: rowspan in read_html failed · Issue #60210 · pandas-dev/pandas (original) (raw)

Pandas version checks

Reproducible Example

import pandas as pd

html string

s = '

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Đơn vị tính: Việt Nam đồng
Tổng giới hạn bồi thường / năm / ngườiChương trình 1Chương trình 2Chương trình 3
50,000,000100,000,000200,000,000
Tử vong do tai nạn50,000,000100,000,000200,000,000
Thương tật toàn bộ vĩnh viễn/ năm50,000,000100,000,000200,000,000
Thương tật bộ phận vĩnh viễn/ năm50,000,000100,000,000200,000,000
Chi phí y tế điều trị thương tật do tai nạn/ năm10,000,00020,000,00030,000,000
'

print(pd.read_html(s))

Issue Description

I have a HTML string (with rowspan attribute), here is how it look when rendering
image

Then I convert to dataframe by using pd.read_html command (pandas 2.2.3), here is how it looks:
image

Totally wrong, the row of 50000000, 100000000 and 200000000 should be aligned to the right.

Expected Behavior

the row of 50000000, 100000000 and 200000000 should be aligned to the right

Installed Versions

INSTALLED VERSIONS

commit : 0691c5c
python : 3.10.9
python-bits : 64
OS : Linux
OS-release : 5.15.0-124-generic
Version : #134~20.04.1-Ubuntu SMP Tue Oct 1 15:27:33 UTC 2024
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.2.3
numpy : 1.26.4
pytz : 2022.7
dateutil : 2.8.2
pip : 24.3.1
Cython : None
sphinx : 5.0.2
IPython : 8.10.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.3.1
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.2
lxml.etree : 4.9.1
matplotlib : None
numba : N/A
numexpr : 2.8.4
odfpy : None
openpyxl : 3.1.3
pandas_gbq : None
psycopg2 : 2.9.9
pymysql : None
pyarrow : 16.1.0
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.10.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 2.0.1
xlsxwriter : 3.2.0
zstandard : 0.19.0
tzdata : 2024.1
qtpy : None
pyqt5 : None