I have below code which generates a sample side with layout 1 with Title
as Summary Table
from pd2ppt import df_to_powerpoint
from pd2ppt import df_to_table
import pandas as pd
from pptx import Presentation
from pptx.util import Inches
path =r"mypath\Sample PPT.pptx"
prs = Presentation(path)
title_slide_layout = prs.slide_layouts[1]
slide = prs.slides.add_slide(title_slide_layout)
title = slide.shapes.title
title.text = "Summary Table"
prs.save(path)
Now in the same slide, I want a dataframe
in the placeholder section.
Sample df:
df = pd.DataFrame(
{'District':['Hampshire', 'Dorset', 'Wiltshire', 'Worcestershire'],
'Population':[25000, 500000, 735298, 12653],
'Ratio':[1.56, 7.34, 3.67, 8.23]})
My Code:
df_to_powerpoint(
r"mypath\Sample PPT.pptx", df)
The above code works and gets me a df on a slide but it outputs the data in the next slide and not on the same slide where I printed title
as Summary Table
.
All in all, I want the df and the title in one slide
Any help please?