Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 19054

Is it possible to turn Mathjax off in Pandas and/or Jypyter Notebook?

$
0
0

It has already been discussed here that Mathjax interprets dollar sign $ as start of its code. String within Pandas dataframes when rendered in Jupyter Notebook get garbled if they contain a dollar sign.

Official docs at https://pandas.pydata.org/docs/user_guide/options.html suggest that mathjax in pandas can be disabled by switches:

pd.set_option('display.html.use_mathjax', False)

pd.set_option('styler.html.mathjax', False)

I turned both options off - and nothing changed, my notebook still displayed large bold italic font without spaces after dollar signs.

By trial and error I figured out that mathjax formatting disappears only if column width is set to less than 135. What is more, only selected cells are formatted: of two cells in the same row that contain the same strings first is plain text, second is mathjax'ed. In the same column, top row triggers mathjax, bottom does not. Compare these two dataframe views.

Mathjax starts formatting top right text field pd.set_option('max_colwidth', 135)

Dataframe with colwidth of 135

Mathjax does not format text field pd.set_option('max_colwidth', 134)

Dataframe with colwidth of 134

So it appears that mathjax for dataframe cannot be turned off in Jupyter Notebook by pandas option.

Has anyone dealt with that problem, and is there any way to kill mathjax completely?

UPD Running Jupyter notebook 7.0.6, pandas 2.1.4.


Viewing all articles
Browse latest Browse all 19054

Trending Articles