我试图从包含300多行SQL数据的Pandas数据框中创建pdf,我试图使用fpdf库,但我似乎运气不佳,这是我尝试过的代码:
cursor.execute(query)
records = cursor.fetchall()
df_custdata = pd.DataFrame(records)
df_custdata.columns = ['Date', 'Gross', 'Net', 'Margin', 'D/D Gross']
pdf=FPDF()
pdf.add_page()
pdf.set_font("Arial", size=6.5)
pdf.cell(200, 10, txt="this is the yearly report", ln=1,
align="")
for i in range(len(df_custdata)):
pdf.cell(100, 10, '%s' % (df_custdata.iloc[i]), ln=1,
align="C")
pdf.output("pdf_file_name.pdf")
As you can see that is the kind of output I have been getting,我需要数据看起来像一个适当的表,顶部有标题,标题下的单元格中有数据,如果您能告诉我如何删除“0 Name:0,dtype:object”,那就太好了
目前没有回答
相关问题 更多 >
编程相关推荐