0

I am trying to create all combinations of items from four fields in my dataframe. I'm testing the code below, and something is wrong because I keep getting 'out of memory' errors.

import itertools
A = df['ID']
B = df['PRICE']
C = df['YIELD']
D = df['SCORE']
a = [A, B, C, D]

data = list(itertools.product(*a))
idx = ['c{}'.format(i) for i in range(1, len(data)+1)]
df = pd.DataFrame(data, index=idx, columns=list('abc')).T

df

I have 10,000 rows of data in this example. In other dataframes there will be many more rows. Is this possible, or is the resulting object just too large?

Georgy
  • 12,464
  • 7
  • 65
  • 73
ASH
  • 20,759
  • 19
  • 87
  • 200

0 Answers0