Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get rid of italics in Ipython Pandas and get plain text?

I am saving text to csv file in Python 3. Text is clean and does not have any tags. Here is how it looks in Notepad: enter image description here

Here is my text bulb:

  unicodedata.normalize('NFKD',' '.join(i[1:-1]) 
).encode('ascii','ignore').decode()

Here is how I save it:

def save(filename, data):
    with open(r"path to file\{}.csv".format(filename),"a",encoding="utf-8"  ) as f:
        w = csv.DictWriter(f, [coulm names],lineterminator="\n")
        w.writeheader()
        w.writerows(data[:10])

When I open file in Ipython Pandas as DataFrame I can see different styling of text like this: enter image description here

How do I get rid of it and make all text look the same? P.S. everything looks fine in gsheets: enter image description here PS. I use the follofing command in pandas:

data_full = pd.read_csv("restaurant_menu_with_entryurl_full.csv", encoding = 'utf8')

PS. Also if I select single column view in pandas the text looks uniform. enter image description here

like image 430
Billy Jhon Avatar asked Sep 17 '25 16:09

Billy Jhon


1 Answers

I was having the same issue. After digging a bit I found out that there is an option on Pandas to disable MathJax. Try doing this right after you import pandas:

import pandas as pd
pd.set_option('display.html.use_mathjax', False)

Reference for more display options on pandas: https://pandas.pydata.org/pandas-docs/stable/user_guide/options.html

From the link above:
"When True, Jupyter notebook will process table contents using MathJax, rendering mathematical expressions enclosed by the dollar symbol."

like image 105
Mr Orange Avatar answered Sep 19 '25 08:09

Mr Orange