Last active
April 7, 2021 00:43
-
-
Save scdub/b0ac871dbb54e68c136d346a55e517a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import pandas as pd | |
values = [('A', 'B', 'C'), | |
('1', '2', '3'), | |
('P', 'Q', 'R')] | |
df = pd.DataFrame([''.join(p) for p in itertools.product(*values)]) | |
""" | |
0 | |
0 A1P | |
1 A1Q | |
2 A1R | |
3 A2P | |
4 A2Q | |
5 A2R | |
6 A3P | |
7 A3Q | |
8 A3R | |
9 B1P | |
10 B1Q | |
11 B1R | |
12 B2P | |
13 B2Q | |
14 B2R | |
15 B3P | |
16 B3Q | |
17 B3R | |
18 C1P | |
19 C1Q | |
20 C1R | |
21 C2P | |
22 C2Q | |
23 C2R | |
24 C3P | |
25 C3Q | |
26 C3R | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
there is a little typo up there where
lists
is used instead ofvalues
...df = pd.DataFrame([''.join(p) for p in itertools.product(*values)])