Provide styling option to escape dollar signs
See original GitHub issueJupyter 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 $200 million to $700 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
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
@TomAugspurger I added a new
pd.options.display.html.use_mathjax
option (see #19856).There’s a few reasons why I think this is better than the
pd.options.display.html.classes
approach:'text2jax_ignore'
from your above comment but this actually did not disable MathJax. It’s easy to make a typo – the correct class name is'tex2jax_ignore'
. By using a boolean option, we reduce user error.'dataframe'
class name in an option. This might prevent other classes having their own_repr_html_
and class name.@TomAugspurger Thanks for your feedback! I’ll look into this route and get back to you.