79706274

Date: 2025-07-18 13:53:55
Score: 0.5
Natty:
Report link

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 │
└────────┴───────┴───────┘
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Erik-Jan van Kesteren