I have product purchase count data which looks likes this:
user item1 item2
a 2 4
b 1 3
c 5 6
... ... ...
These data are imported into python
using numpy.genfromtxt
. Now I want to process it to get the correlation between item1
purchase amount and item2
purchase amount -- basically for each value x
of item1
I want to find all the users who bought item1
in x
quantity then average the item2
over the same users. What is the best way to do this? I can do this by using for
loops but I thought there might be something more efficient than that. Thanks!