Question
Use Python programming to find most popular single products and co-purchased products from the large transaction data: retail.csv. Each row in the file is one
Use Python programming to find most popular single products and co-purchased products from the large transaction data: retail.csv. Each row in the file is one purchase transaction from a customer, including a set of product ids separated by commas. The first column is transaction ID, column 2-3 are the products ID purchased in this transaction. It is worth mentioning that if the value in third column is zero, it means this customer only purchased one product (the one in second column).
Note:
Co-purchased products is defined as a pair of products purchased in the same transaction. For example a row is: "2 24 35". Then 24 and 35 is a pair of copurchased products IDs,.
To find co-purchased product in each transaction, you might use a nested loop.
Write top 10 single products and top 10 co-purchased product pairs into a new file: output.txt
Retail.csv:
A B C 1 5 2 2 29 0 3 3 26 28 4 4 28 8 5 5 28 9 6 6 24 0 7 7 22 0 8 8 20 0 9 9 16 0 10 10 1 14 11 11 4 13 12 12 9 28 13 13 7 17 14 14 17 22 15 15 26 4 16 16 5 0 17 17 1 0 18 18 19 27 19 19 10 15 20 20 22 0 21 21 23 22 22 23 10Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started