Provide styling option to escape dollar signs (original) (raw)

Jupyter Notebooks use MathJax to render text between dollar signs. Sometimes this is appropriate and sometimes it is not.

import pandas as pd df=pd.DataFrame({'A':['From 200millionto200 million to 200millionto700 million','$20+']}) df

It appears that the official guidance is to use $\$$ to render a single $ symbol.

df.A = df.A.str.replace('$', '$$$') df

However, editing the data to tune the rendering is messy. I'm hoping this can be incorporated into the new Pandas styling module. Perhaps something like df.style.escape_dollar().

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.32-696.13.2.el6.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.22.0
pytest: 3.4.0
pip: 9.0.1
setuptools: 38.4.0
Cython: None
numpy: 1.14.0
scipy: None
pyarrow: 0.8.0
xarray: None
IPython: 6.2.1
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: 0.4.0
matplotlib: 2.1.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None