question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide styling option to escape dollar signs

See original GitHub issue

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 $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:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
davidchallcommented, Feb 24, 2018

@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:

  • Less error-prone: I copied '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.
  • Easier to find: When I experience this issue, I am likely to search for terms like “MathJax”, “LaTeX”, “dollar symbol”, and “italic”. I’m not likely to search for the ability to change an HTML class attribute. This requires knowledge of how MathJax works.
  • Smaller change: While the ability to add arbitrary class attributes to the table might be useful in the future, this is a more substantial change. For example, I’m not convinced it makes sense to keep the 'dataframe' class name in an option. This might prevent other classes having their own _repr_html_ and class name.
0reactions
davidchallcommented, Feb 23, 2018

@TomAugspurger Thanks for your feedback! I’ll look into this route and get back to you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS character escape sequences - Mathias Bynens
Instead, you'll have to escape the weird characters (in this case, the second # ). Doing so will cancel the meaning of special...
Read more >
How can I escape a $ dollar sign in a docker compose file?
You can use a $$ (double-dollar sign) when your configuration needs a literal dollar sign. You are hitting the docker-compose variable ...
Read more >
Using character escapes in markup and CSS - W3C
CSS represents escaped characters in a different way. Escapes start with a backslash followed by the hexadecimal number that represents the ...
Read more >
Provide a way for escaping the dollar sign symbol ... - YouTrack
Dollar escaping : Provide means to escape $ in multiline strings. The nicest and the most natural way to do it is via...
Read more >
57136 – EL Parser escaping dollar sign not ${ or ${...}
Either the JSP style escaping or the EL style could be viewed as correct. ... Thank you for providing a configuration option for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found