0

I have a dataFrame that looks like this

     Bag  Blush Nail Polish Brushes Concealer   Eyebrow Pencils Bronzer Lip liner   
0    0     1        1       0       1       0       0       1        1
1    0     0        1       1       0       1       0       0        1

that contains 1000 entries which show transaction data. If the person bought the item it is 1 and if they did not buy it is 0. I am using the Manhattan norm as the 'distance' between each transaction. I created my function as

#Using the Manhattan norm
def Mn(v):
 return sum(v)
manhattan_norm=lambda x,y: Mn((x-y)%2)

I am trying to apply this function to the dataframe to get an output that shows the distance between the transactions. I was able to do it when I assigned row 1 and 2 by x and y but can not get it to work through the whole dataframe row by row. Thank you for any help.

wjandrea
  • 28,235
  • 9
  • 60
  • 81
John
  • 1
  • 1
  • I assume you're using Pandas, so I added the [tag:pandas] tag for you. If that's incorrect, you can [edit] to fix it. – wjandrea Dec 16 '21 at 04:26
  • Beside the point, but [avoid named lambdas](/q/38381556/4518341), use a `def` instead. – wjandrea Dec 16 '21 at 04:27

0 Answers0