The current answers still did not do exactly what I wanted, so I just published another solution built on polars dataframes: polarsgrid
from polarsgrid import expand_grid
expand_grid(
fruit=["apple", "banana", "pear"],
color=["red", "green", "blue"],
check=[True, False],
)
Which returns the following data frame:
shape: (18, 3)
┌────────┬───────┬───────┐
│ fruit ┆ color ┆ check │
│ --- ┆ --- ┆ --- │
│ str ┆ str ┆ bool │
╞════════╪═══════╪═══════╡
│ apple ┆ red ┆ true │
│ banana ┆ red ┆ true │
│ pear ┆ red ┆ true │
│ apple ┆ green ┆ true │
│ banana ┆ green ┆ true │
│ … ┆ … ┆ … │
│ banana ┆ green ┆ false │
│ pear ┆ green ┆ false │
│ apple ┆ blue ┆ false │
│ banana ┆ blue ┆ false │
│ pear ┆ blue ┆ false │
└────────┴───────┴───────┘