Feb-29-2020, 05:28 AM
(Feb-28-2020, 02:42 PM)Larz60+ Wrote: one method: use two step process:
first convert dataframe to html using pandas.DataFrame.to_html:
https://pandas.pydata.org/pandas-docs/ve..._html.html
next convert html file to pdf using pdfkit (if you need to install, usepip install pdfkit
)
import pdfkit as pdk pdk.from_file(path, htmlfilename)
I have tried like below
import pandas as pd
df = pd.DataFrame(np.random.random((10,3)), columns = ("col 1", "col 2", "col 3"))
df1 =df.to_html(df.info())
pdk.from_file('htm.pdf', df1)
it is not working