report_add_table
report_add_table(doc, data, font_size=TABLE_FONT_SIZE, autofit=True)Add a table to a report.
Adds a data frame in the current slide’s content placeholder (pptx) or as a new table (docx). On a slide the table is styled (rules above and below the header, centred cells, a readable font) and its columns are widened to span the content placeholder, roughly in proportion to each column’s contents, so it fills the slide instead of sitting tiny in a corner. In Word it is added as a plain table with a bold header.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| doc | pptx.Presentation or docx.Document | A document from report_new(). |
required |
| data | pandas.DataFrame | The table. | required |
| font_size | float | Cell font size in points. Default 12. | TABLE_FONT_SIZE |
| autofit | bool | Word only: auto-size columns to content. Default True. | True |
Returns
| Name | Type | Description |
|---|---|---|
| pptx.Presentation or docx.Document | The document. |
See Also
report_add_plot
Examples
>>> doc = report_add_table(report_new("docx"), calc_percentage(podracing_survey, "demo_gender"))