How to display <IPython.core.display.HTML object>?

Siamak Abdi picture Siamak Abdi · Sep 11, 2019 · Viewed 9.2k times · Source

I try to run the below codes but I have a problem in showing the results. also, I use pycharm IDE.

from fastai.text import *

data = pd.read_csv("data_elonmusk.csv",  encoding='latin1')
data.head()

data = (TextList.from_df(data, cols='Tweet')
                .split_by_rand_pct(0.1)
                .label_for_lm()
                .databunch(bs=48))

data.show_batch()

The output while I run the line "data.show_batch()" is:

IPython.core.display.HTML object

Answer

Matteo De Stefano picture Matteo De Stefano · Sep 9, 2020

If you don't want to work within a Jupyter Notebook you can save data as an HTML file and open it in a browser.

with open("data.html", "w") as file:
    file.write(data)