Latex formula in Pandas DataFrame

Interestingly, if you output only one field of the dataframe it works:

df['Case1']['Formula1']

𝑥−1

However, when the whole dataframe is taken into account you cannot use Latex objects. It is enough to use only LaTeX formulas between $$ characters:

my_dict = {'Case1':{'Formula1':'$$x^{-1}$$', 'Formula2':'$$x^2$$'},
           'Case2':{'Formula1':'$$x^{-2}$$', 'Formula2':'$$x^4$$'}}
df = pd.DataFrame(my_dict)
display(df.transpose())

enter image description here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top