Skip to content

Commit ab81604

Browse files
committed
test: add test for creating table with Polars LazyFrame support
1 parent 05ddfc9 commit ab81604

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/test_table.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff 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")

0 commit comments

Comments
 (0)