File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -98,3 +98,40 @@ def test_create_table_with_polars_dataframe(output: pathlib.Path) -> None:
9898 .build ()
9999 )
100100 presentation .save (output / "table_polars_data.pptx" )
101+
102+
103+ @pytest .mark .skipif (not USE_POLARS , reason = "Polars not installed" )
104+ def test_create_table_with_polars_lazyframe (output : pathlib .Path ) -> None :
105+ """Test creating a table with polars LazyFrame."""
106+ # Type checking is done at runtime when polars is available
107+ import polars as pl # type: ignore[import]
108+
109+ # Create polars LazyFrame with simple data using dictionary
110+ data = {
111+ "カテゴリ" : ["食品" , "電化製品" , "衣類" ],
112+ "売上" : [5000 , 12000 , 8000 ],
113+ "利益率" : [0.2 , 0.15 , 0.25 ],
114+ }
115+ lazy_df = pl .LazyFrame (data )
116+
117+ # Collect LazyFrame to DataFrame
118+ df = lazy_df .collect ()
119+
120+ # Convert DataFrame to a list of lists for table creation
121+ table_data = [df .columns ] + df .to_numpy ().tolist ()
122+
123+ presentation = (
124+ pptxr .Presentation .builder ()
125+ .slide (
126+ pptxr .SlideBuilder ().table (
127+ table_data ,
128+ left = (100 , "pt" ),
129+ top = (100 , "pt" ),
130+ width = (400 , "pt" ),
131+ height = (200 , "pt" ),
132+ first_row_header = True ,
133+ )
134+ )
135+ .build ()
136+ )
137+ presentation .save (output / "table_polars_lazyframe_data.pptx" )
You can’t perform that action at this time.
0 commit comments