Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
df = pd.DataFrame(dict(c1=pd.Series(range(3),dtype='int64'),
c2=pd.Series(range(3),dtype='Int64'),
c3=pd.Series(range(3),dtype='float64'),
c4=pd.Series(range(3),dtype='string'),
c5=pd.Series([0,1,0],dtype='bool'),
c6=pd.Series([0,1,0],dtype='boolean'),
))
formatter = {c:lambda x: f"[{x}]" for c in df.columns}
display(HTML(df.to_html(formatters=formatter)))
c1 | c2 | c3 | c4 | c5 | c6 | |
---|---|---|---|---|---|---|
_ | [0] | 0 | [0.0] | 0 | [False] | False |
_ | [1] | 1 | [1.0] | 1 | [True] | True |
_ | [2] | 2 | [2.0] | 2 | [False] | False |
Problem description
DataFrame.to_html(formatters=formatters) is not working for MaskedArrays (new arrays with missing values)
Expected Output
formatters should also be applied to MaskedArrays.
Output of pd.show_versions()
INSTALLED VERSIONS
commit : 2a7d332
python : 3.8.5.final.0
python-bits : 64
OS : Linux
OS-release : 4.19.76-linuxkit
Version : #1 SMP Tue May 26 11:42:35 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.2
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.3
setuptools : 49.6.0.post20200917
Cython : 0.29.21
pytest : 6.0.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.3.4
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : 4.9.1
bottleneck : 1.3.2
fsspec : 0.8.2
fastparquet : None
gcsfs : None
matplotlib : 3.2.2
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : 1.0.1
pytables : None
pyxlsb : None
s3fs : 0.2.2
scipy : 1.5.2
sqlalchemy : 1.3.19
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.16.1
xlrd : 1.2.0
xlwt : None
numba : 0.48.0