2

I have a big dataframe (more than 100 rows) and I would like to get a scrollbar for the dataframe in the HTML output. Currently before I save it to HTML the scrollbar is there for the dataframe, to scroll down and see the all the rows, but when I save it to HTML the scrollbar disappears and I get a really long table in the html output. I tried to do it by reducing the rows with pd.set_option("display.max_rows", 1) but it doesn't work. Can someone help?

  • This doesn't seem to be a question related to `pandas`. Have you tried the solution in [this post](https://stackoverflow.com/questions/8232713/how-to-display-scroll-bar-onto-a-html-table)? – Henry Yik Apr 28 '20 at 08:26
  • I don't think that this is the case. It has to do with the output in pandas to html. I can't use that code to get a scrollbar in python – Alexandros Giannakakis Apr 29 '20 at 07:59

1 Answers1

1

save pandas DataFrame to HTML first:

  html = df.to_html()
  text_file = open("datatable.html", "w")
  text_file.write(html)
  text_file.close()

Then in HTML file:

<iframe src="datatable.html"  height=300px width=800px border=0></iframe>