I have an array which hold an integer value and item Id value in it.
I want to add two different values of two different items. For example, let's say foretold item is like this:
array1 = [[12, 1], [23, 2], [34, 3]]
and the desired output should be something like that:
[[35, 12, 1, 23, 2], [46, 12, 1, 34, 3], [57, 23, 2, 34, 3]]
For small array counts there is no problem but when the count of array exceed a hundred I encounter with huge performance problems.
Is there any method for this in Python?
My example code:
for item1 in array1:
for item2 in array1:
sumTwoOutput.append([item1[0] + item2[0], item1[0], item1[1], item2[0], item2[1]])
dfSumTwoOutput = pd.DataFrame(sumTwoOutput)
dfSumTwoOutput.columns = ["OutputSum", "Value1", "ItemId1", "Value2", "ItemId2"]