Dec-27-2021, 08:11 AM
I have the following dictionary:
the_dictionary_list = {'Fondo': ['Oceano.png'], 'Cuerpo': ['Cuerpo_cangrejo.png'], 'Ojos': ['Antenas.png', 'Pico.png', 'Verticales.png'], 'Color': ['Amarillo.png', 'Blanco.png', 'Rojirosado.png', 'Turquesa.png', 'Verde_oscuro.png', 'Zapote.png'], 'Pinzas': ['None', 'Pinzitas.png', 'Pinzotas.png', 'Pinzota_pinzita.png'], 'Puas': ['None', 'Arena.png', 'Marron.png', 'Purpura.png', 'Verde.png']}And to get each possible permutation without repetition in a specific order (i.e. cartesian products) I use the following code:
import itertools as it AllKeysNames = ['Fondo', 'Cuerpo', 'Ojos', 'Color', 'Pinzas', 'Puas'] Combinations = list(it.product(*(the_dictionary_list[Name] for Name in AllKeysNames))) print(f'{Combinations}')How can I make the above program saves each iteration to a dataframe such as it throws an output like this one:
Output:Index | Permutations | FilePermutations
0 |Fondo+Cuerpo+Ojos+Color+Pinzas+Puas|Oceano.png+Cuerpo_cangrejo.png+Antenas.png+Amarillo.png+None+None
1 |Fondo+Cuerpo+Ojos+Color+Pinzas+Puas|Oceano.png+Cuerpo_cangrejo.png+Antenas.png+Amarillo.png+None+Arena.png
2 |Fondo+Cuerpo+Ojos+Color+Pinzas+Puas|Oceano.png+Cuerpo_cangrejo.png+Antenas.png+Amarillo.png+None+Marron.png
.
.
.
The information within the Permutations
column will remain constant, and the dataframe would ended up with an index length of 359
.