I have some taps. There are n of them. Each tap can either be off or on. I would like to generate a dataframe of all of the possible states that my set of taps could be in. For example if
n=2
Then I would like to generate the dataframe
I have some taps. There are n of them. Each tap can either be off or on. I would like to generate a dataframe of all of the possible states that my set of taps could be in. For example if
n=2
Then I would like to generate the dataframe
Use itertools.product
with DataFrame
constructor:
from itertools import product
n = 2
df = pd.DataFrame(list(product(range(2), repeat=n)))
print (df)
0 1
0 0 0
1 0 1
2 1 0
3 1 1