Reputation: 41
I am reading an Excel file in Jupyter, which contains income data, e.g. $2,500 to $4,999. Rendered output is returning:
How can I avoid this formatting?
Upvotes: 4
Views: 3847
Reputation: 535
In pandas>=0.23.0
, you can prevent MathJax from rendering perceived LaTeX found in DataFrames. This is achieved using:
import pandas as pd
pd.options.display.html.use_mathjax = False
Upvotes: 5
Reputation: 187
In Jupyter you can use a backslash ( \
) before the dollar sign to avoid starting a LaTeX math block.
So write \$2,500
in your markdown instead of $2,500
.
A markdown cell like this:
Characterisic | Total with Income| \$1 to \$2,499 | \$2,500 to \$4,999
--------------|------------------|----------------|--------------
data | data |data | data
data | data |data | data
will be rendered by Jupyter like so:
If the table is handled with typical Jupyter tools (python,numpy,pandas) you can alter the column names with a short code snippet.
The snippet below will replace all $
strings in the column names with \$
so that Jupyter will render them without LaTeX math.
import pandas as pd
data = pd.read_excel("test.xlsx")
for col in range(0, len(data.columns.values)):
data.columns.values[col] = data.columns.values[col].replace("$", "\$")
data
Before and after screenshot:
Upvotes: 1