I'm working on beginner data analysis with numpy on Python. I've this piece of code:
## column = [product]
## row = [client]
## value 1 means that a product has been purchased .
cart = np.array([[1, 1, 1, 1],
[1, 0, 1, 1],
[1, 1, 0, 0],
[0, 1, 1, 1]])
I want to know how can I select the columns above two by two to print at the end how much each pairs of products were purchased. Also I need to find which pair of products was the most purchased.
Where each tuple (u, v, n) means that products u and v are purchased together n times (per n customers). The output will be:
[(0,1,2), (0,2,2), (0,3,2), (1,2,2), (1,3,2), (2,3,3)]
(2,3,3) -> the most purchased.
Thanks.